From 3462c3c752d44364e7b90eebfcc5083f96c45172 Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Thu, 31 Jan 2008 19:38:26 +0000 Subject: [PATCH] When reinitializing a lockuser, don't assume that the lock is in use. If it is in use, use the watched request, otherwise use the lockuser's own request. Only allocate a lockuser request if both requests are null. PR: 119920 Tested by (6.x): Landon Fuller --- lib/libkse/sys/lock.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/libkse/sys/lock.c b/lib/libkse/sys/lock.c index 77e4e420023c..3620f31f2dfc 100644 --- a/lib/libkse/sys/lock.c +++ b/lib/libkse/sys/lock.c @@ -118,14 +118,22 @@ _lockuser_reinit(struct lockuser *lu, void *priv) { if (lu == NULL) return (-1); - /* - * All lockusers keep their watch request and drop their - * own (lu_myreq) request. Their own request is either - * some other lockuser's watch request or is the head of - * the lock. - */ - lu->lu_myreq = lu->lu_watchreq; + if (lu->lu_watchreq != NULL) { + /* + * In this case the lock is active. All lockusers + * keep their watch request and drop their own + * (lu_myreq) request. Their own request is either + * some other lockuser's watch request or is the + * head of the lock. + */ + lu->lu_myreq = lu->lu_watchreq; + lu->lu_watchreq = NULL; + } if (lu->lu_myreq == NULL) + /* + * Oops, something isn't quite right. Try to + * allocate one. + */ return (_lockuser_init(lu, priv)); else { lu->lu_myreq->lr_locked = 1;