From: didier <dga...@ma...> - 2010-02-26 14:10:20
|
Hi, Le vendredi 19 février 2010 à 14:01 +0100, Frank Lahm a écrit : > 2010/2/19 didier <dga...@ma...>: > > Hi, > > Le mardi 05 janvier 2010 à 08:34 +0100, Anton Starikov a écrit : > > > >> > Locking could be an issue too, for symlink ad_open set adf_fd to 0 but > >> > it's /dev/null. Need to double check all use of adf_fd for a 'closed' 0 > >> > file descriptor. > >> > >> Agree. Will check it. I've been thinking what to put in adf_fd. Probably INT_MIN can be a way, but then it must be checked that negative adf_fd will not introduce some problems later. > > It's a problem with two clients and deleting symlinks. > > first client delete a a symlink: > > afpd call fcntl64(0, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, > > len=0},... > > > > But it never releases the lock, it's done by the OS in close syscall. > > > > Of course afpd never close 0 but 0 is /dev/null, which is shared between > > afpd processes. > > > > After that a second afpd get a BUSY error every time it tries to remove > > a symlink. > > > > I'm adding a test428 showing the pb. > > Good catch! > > The attached patch fixes it for me. It adds checks for fd == 0 in > ad_lock. I haven't committed it yet so that you can review it. I'm afraid it's not enough, if there's no resource fork afpd takes locks on the data fork. I'll commit a wrapper around fcntl which does nothing for fd == 0. There's also pb with: - fstat(), we don't want to fstat(0,...), we have at least one case in getforkparams. - utime(), no lutimes syscall. - and a couple of others :( Didier |