info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Locks continued...


From: raptor
Subject: Locks continued...
Date: Wed, 3 Oct 2001 12:36:34 +0200

hi again,

Now after I have log-info script partialy-working (via fork) I've got
another problem, which may be explain my question why CVS doesn't release
the locks (if I'm right of course, and if I'm right CVS behavior continues
to annoy me !!).
I'm posting my script below, so u can see if there is some error in it.
So here goes :
When I edit files only in one directory and then commit there is no problems
everything works, but if I try to commit when files had been changed in many
dirs the following happens (or atleast I imagaine it work that way from the
results I got on the screen):

say I have this tree structure :
/cvstest/remote/mytest/test1
/cvstest/remote/mytest/test2
/cvstest/remote/mytest/blah/blahtest

1. CVS walks and see test1 and test2 has to be commited 'cause they are
changed
2. test1 and test2 are commited
3. CVS call log-info script
4. log-info is started and it forks process to do the main-working copy
update
5. Meanwhile CVS continues to check blah-dir and see that blahtest has to be
updated too
6. BUT we are updating at the moment and CVS now stops waiting for lock to
be freed (which doesn't happen)
7... !!

I'm may be mistaken but that is what i see, the main point is that it seems
that CVS want to hold that lock 'cause it fires log-info script on every
directory i.e. something like this happen in reality :

commit-dir1, exec-loginfo-on-dir1,
commit-dir2, exec-loginfo-on-dir2,
..............
commit-dirX, exec-loginfo-on-dirX..

AGAIN I'm not totaly sure, just wondering.... and 'cause I'm not a C
programmer I can't easily follow the CVS-source to see the exact behaviour.

Any ideas how can I solve the problem with many directories and/or
explanation of the exact process...
=====
iVAN
address@hidden
=====

=================THE SCRIPT=================
#!/usr/bin/perl
#Author : iVAN
use Sys::Syslog qw(:DEFAULT setlogsock);
use strict;
my $userName = getpwuid($<);
my $cvs = '/usr/bin/cvs';
my $repo = '/arh/cvs';
my $lockfile = '/arh/cvs/CVSROOT/update.lock';
my $workcopy = '/cvstest/mytest';
my $pass = 'blah';

use constant DEBUG => 0;
sub LOCK_SH {1};
sub LOCK_EX {2};
sub LOCK_UN {8};

sub update {
    print "Parent-ID : $$\n";
    fork and exit;
    print "User: $userName, child-ID : $$\n";
    system "cd $workcopy && $cvs -d $repo update -d -A";
    my $status = 'ERROR: Can not update the working copy';
    loging $status if DEBUG && $? > 0;
    die "$status" if $? > 0;
};

sub loging {
    my $msg = shift;
    setlogsock('unix');
    openlog 'cvs.loginfo', '', 'user';
    syslog 'info', $msg;
    closelog;
};

#================= MAIN
 #get the all info
undef $/;
my $msg = <STDIN>;
 #now check to see if the log message begins with '!'
unless ( $msg =~ /Log Message:.!/gs) {
    print "$userName---------\n";
    print "$msg\n";
    print "---------\n";

}# we will do our actions then
else {
 print "-!- used, now will try to update the Dev-working copy.....\n";
 my $status = "Can't open lock file";
 open FILE,"<$lockfile" or die "$status";
 flock FILE, LOCK_EX;
 update;
 flock FILE, LOCK_UN;
 close FILE;
 $status = 'Working copy successfuly updated !';
 loging $status if DEBUG;
 print $status,"\n";
};






reply via email to

[Prev in Thread] Current Thread [Next in Thread]