Subject: Re: [netatalk-admins] movieplayer and such with afpd

From: [email-masked]
Date: Sun, 14 Dec 1997 13:14:55 -0500

Here's the big block comment about the synchronization lock code in
fork.c:

    /*
     * Perform synchronization locks.  There are a couple of ways of
     * doing this.  The method we're using here, translates W & !R
     * to EX, and R & !W to SH.  This will allow multiple readers
     * and one writer.  An alternate method translates R & W to SH,
     * and !R & !W to EX.  This allows multiple writers, but limits
     * the reads to one, which doesn't make much sense, since most
     * apps will want to read *and* write.
     *
     * Note:  By doing this, there's pretty much no point in doing
     * byte range locking.  If you open for writing, you have a lock
     * no one else can break.
     *
     * One last thing:  We do the locking late, so we can still return
     * data on a "Deny Conflict" error.
     */

:wes

---

From: a sun <[email-masked]>
Date: Mon, 15 Dec 1997 12:54:59 -0800 (PST)

okay, i believe byte locks should make possible a much improved
locking mechanism. how about doing the following for locks?

	1) on an open fork, test access for read/write by attempting
	   to set a read/write lock. return a AFPERR_LOCK on a write
	   lock failure and AFPERR_ACCESS on a read lock failure.

	2) if that succeeds, unset that lock and reset it to
	   correspond to the requested deny modes. i.e., deny read
	   gets a write lock and deny write gets a read lock. return
	   the appropriate error on failure to set that as well.

there's a minor race condition between 1 and 2, but i'm not sure how
important that is. in the worst possible case, #2 might fail when it
should have succeeded, resulting in an error message. currently,
afp_read, afp_write, afp_setforkparams, and deletefile set locks. i
believe that covers anything that goes through the adouble
library. needless to say, the old behaviour is the default one under
afs due to it lacking byte locks.

so, does anyone see any problems with this setup? am i missing places
that need byte lock protection?

-a