Subject: Why lock a file when reading?
From: Jan-Erik M}ngs (kire@nada.kth.se)
Date: Wed Mar 30 1994 - 13:33:02 EST
bg@nada.kth.se who has taken care of netatalk here sent me the
following patch ("why lock a file while reading?"). Any comments, is
this wrong?
-Kire
bg$ rcsdiff -c -r1.3 fork.c
===================================================================
RCS file: RCS/fork.c,v
retrieving revision 1.3
diff -c -r1.3 fork.c
*** 1.3 1994/02/23 16:28:13
--- fork.c 1994/03/29 10:26:12
***************
*** 210,216 ****
} else {
lockfd = ad_hfileno( &oforks[ ofrefnum ]->of_ad );
}
! if ( lockop && flock( lockfd, lockop|LOCK_NB ) < 0 ) {
ad_close( &oforks[ ofrefnum ]->of_ad, adflags );
free( oforks[ ofrefnum ]->of_name );
free( oforks[ ofrefnum ] );
--- 210,224 ----
} else {
lockfd = ad_hfileno( &oforks[ ofrefnum ]->of_ad );
}
! if ( !lockop )
! /* no need to lock */;
! else if ( flock( lockfd, lockop|LOCK_NB ) == 0)
! /* obtained lock successfully */;
! else if ( lockop == LOCK_SH && errno == EACCES ) {
! /* allow read access but don't lock */
! errno = 0;
! }
! else {
ad_close( &oforks[ ofrefnum ]->of_ad, adflags );
free( oforks[ ofrefnum ]->of_name );
free( oforks[ ofrefnum ] );
bg$
This archive was generated by hypermail 2b28 : Sat Dec 18 1999 - 16:20:52 EST