svn commit: samba r16987 - in branches/SAMBA_3_0/source/locking: .

jra at samba.org jra at samba.org
Wed Jul 12 16:32:03 GMT 2006


Author: jra
Date: 2006-07-12 16:32:02 +0000 (Wed, 12 Jul 2006)
New Revision: 16987

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16987

Log:
Fix the logic errors in ref-counting Windows locks.
Hopefully will fix the build farm. Still a few errors
in RAW-LOCK to look at though...
Jeremy.

Modified:
   branches/SAMBA_3_0/source/locking/brlock.c
   branches/SAMBA_3_0/source/locking/posix.c


Changeset:
Modified: branches/SAMBA_3_0/source/locking/brlock.c
===================================================================
--- branches/SAMBA_3_0/source/locking/brlock.c	2006-07-12 16:31:59 UTC (rev 16986)
+++ branches/SAMBA_3_0/source/locking/brlock.c	2006-07-12 16:32:02 UTC (rev 16987)
@@ -1225,6 +1225,7 @@
 	uint16 tid = fsp->conn->cnum;
 	int fnum = fsp->fnum;
 	unsigned int i, j, dcount=0;
+	int num_deleted_windows_locks = 0;
 	struct lock_struct *locks = (struct lock_struct *)br_lck->lock_data;
 	struct process_id pid = procid_self();
 	BOOL unlock_individually = False;
@@ -1289,6 +1290,7 @@
 		if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid)) {
 			if ((lock->lock_flav == WINDOWS_LOCK) && (lock->fnum == fnum)) {
 				del_this_lock = True;
+				num_deleted_windows_locks++;
 			} else if (lock->lock_flav == POSIX_LOCK) {
 				del_this_lock = True;
 			}
@@ -1334,8 +1336,10 @@
 		}
 	}
 
-	/* Reduce the lock reference count on this dev/ino pair. */
-	reduce_windows_lock_ref_count(fsp, dcount);
+	if (num_deleted_windows_locks) {
+		/* Reduce the Windows lock reference count on this dev/ino pair. */
+		reduce_windows_lock_ref_count(fsp, num_deleted_windows_locks);
+	}
 }
 
 /****************************************************************************

Modified: branches/SAMBA_3_0/source/locking/posix.c
===================================================================
--- branches/SAMBA_3_0/source/locking/posix.c	2006-07-12 16:31:59 UTC (rev 16986)
+++ branches/SAMBA_3_0/source/locking/posix.c	2006-07-12 16:32:02 UTC (rev 16987)
@@ -981,6 +981,7 @@
 	 */
 
 	if(!posix_lock_in_range(&offset, &count, u_offset, u_count)) {
+		increment_windows_lock_ref_count(fsp);
 		return True;
 	}
 
@@ -1004,13 +1005,13 @@
 	
 	if ((l_ctx = talloc_init("set_posix_lock")) == NULL) {
 		DEBUG(0,("set_posix_lock_windows_flavour: unable to init talloc context.\n"));
-		return True; /* Not a fatal error. */
+		return False;
 	}
 
 	if ((ll = TALLOC_P(l_ctx, struct lock_list)) == NULL) {
 		DEBUG(0,("set_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
 		talloc_destroy(l_ctx);
-		return True; /* Not a fatal error. */
+		return False;
 	}
 
 	/*
@@ -1108,6 +1109,9 @@
 	DEBUG(5,("release_posix_lock_windows_flavour: File %s, offset = %.0f, count = %.0f\n",
 		fsp->fsp_name, (double)u_offset, (double)u_count ));
 
+	/* Remember the number of Windows locks we have on this dev/ino pair. */
+	decrement_windows_lock_ref_count(fsp);
+
 	/*
 	 * If the requested lock won't fit in the POSIX range, we will
 	 * pretend it was successful.
@@ -1117,18 +1121,15 @@
 		return True;
 	}
 
-	/* Remember the number of Windows locks we have on this dev/ino pair. */
-	decrement_windows_lock_ref_count(fsp);
-
 	if ((ul_ctx = talloc_init("release_posix_lock")) == NULL) {
 		DEBUG(0,("release_posix_lock_windows_flavour: unable to init talloc context.\n"));
-		return True; /* Not a fatal error. */
+		return False;
 	}
 
 	if ((ul = TALLOC_P(ul_ctx, struct lock_list)) == NULL) {
 		DEBUG(0,("release_posix_lock_windows_flavour: unable to talloc unlock list.\n"));
 		talloc_destroy(ul_ctx);
-		return True; /* Not a fatal error. */
+		return False;
 	}
 
 	/*



More information about the samba-cvs mailing list