Changeset 10


Ignore:
Timestamp:
11/20/10 20:31:08 (14 years ago)
Author:
nanardon
Message:
  • paralize path update
Location:
web/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • web/trunk/bin/sophie_scan

    r9 r10  
    7070    if (my $pid = fork()) { 
    7171    } else { 
    72         foreach my $pathkey (@pkey) { 
    73             my @delta = Sophie::Base::RpmsPath->new($pathkey) 
    74                 ->find_delta; 
    75             while (my @d = splice(@delta, 0, 25)) { 
    76                 my $path = Sophie::Base::RpmsPath->new($pathkey); 
    77                 $path->update_content(@d); 
    78                 $path->db->disconnect; 
     72 
     73 
     74        my $NB_PAR = 2; 
     75        my @split; 
     76        my $div = @pkey / $NB_PAR; 
     77 
     78        for (my $i = 0; $i < $NB_PAR - 1; $i++) { 
     79            $split[$i] = [ splice(@pkey, 0, $div) ]; 
     80        } 
     81        $split[$NB_PAR -1] = [ @pkey ]; 
     82        foreach my $job (@split) { 
     83            @{$job || []} or next; 
     84 
     85            if (fork()) { 
     86            } else { 
     87 
     88                foreach my $pathkey (@{ $job }) { 
     89                    my @delta = Sophie::Base::RpmsPath->new($pathkey) 
     90                    ->find_delta; 
     91                    while (my @d = splice(@delta, 0, 25)) { 
     92                        my $path = Sophie::Base::RpmsPath->new($pathkey); 
     93                        $path->update_content(@d); 
     94                        $path->db->disconnect; 
     95                    } 
     96                    Sophie::Base::RpmsPath->new($pathkey)->set_updated; 
     97                } 
     98                exit(0); 
    7999            } 
    80             Sophie::Base::RpmsPath->new($pathkey)->set_updated; 
    81100        } 
    82         exit(0); 
     101        1 while(waitpid(-1, 0) <= 0); 
    83102    } 
    84103    return 1; 
  • web/trunk/lib/Sophie/Base/Header.pm

    r2 r10  
    8989                    $content = $enc->decode($content); 
    9090 
     91                    $self->db->pg_savepoint('FILECONTENT'); 
    9192                    $add_content->execute( 
    9293                        $enc && ref $enc ? encode('utf8', $enc->decode($content)) : $content, 
    9394                        $$self, 
    94                         $entry->{count}); 
     95                        $entry->{count}) or do { 
     96                        $self->db->pg_rollback_to('FILECONTENT'); 
     97                    }; 
    9598                } else { 
    9699                } 
Note: See TracChangeset for help on using the changeset viewer.