Return to BSD News archive
Xref: sserve comp.bugs.4bsd:1945 comp.os.386bsd.bugs:569 Newsgroups: comp.bugs.4bsd,comp.os.386bsd.bugs Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!doc.ic.ac.uk!uknet!mcsun!sun4nl!eur.nl!pk From: pk@cs.few.eur.nl (Paul Kranenburg) Subject: Re: flock broken - I could use some help Message-ID: <1993Apr26.170501.12617@cs.few.eur.nl> Sender: news@cs.few.eur.nl Reply-To: pk@cs.few.eur.nl Organization: Erasmus University Rotterdam References: <C5t8wH.Hs@moxie.hou.tx.us> <1993Apr21.184636.1121@cs.few.eur.nl> Date: Mon, 26 Apr 1993 17:05:01 GMT Lines: 37 In <1993Apr21.184636.1121@cs.few.eur.nl> I said: >The problem is a dangling pointer left in the lockf structure belonging to >the current lock holder. The offending process frees its lock structure >after breaking out of sleep() as a result of a signal. Possible fix: >scan the list of waiting locks to remove the lock that isn't going to be >used. Unfortunately, the fix that went with it was totally bogus. This one might do a better job: ------- ufs_lockf.c ------- *** /tmp/da24999 Mon Apr 26 18:57:25 1993 --- ufs/ufs_lockf.c Mon Apr 26 18:55:57 1993 *************** *** 155,160 **** --- 155,175 ---- } #endif /* LOCKF_DEBUG */ if (error = tsleep((caddr_t)lock, priority, lockstr, 0)) { + + /* Don't leave a dangling pointer in block list */ + if (lf_getblock(lock) == block) { + struct lockf **prev; + + /* Still there, find us on list */ + prev = &block->lf_block; + while ((block = block->lf_block) != NOLOCKF) { + if (block == lock) { + *prev = block->lf_block; + break; + } + prev = &block->lf_block; + } + } free(lock, M_LOCKF); return (error); }