svn commit: samba r13830 - in trunk/source/locking: .
jra at samba.org
jra at samba.org
Sat Mar 4 00:16:51 GMT 2006
Author: jra
Date: 2006-03-04 00:16:51 +0000 (Sat, 04 Mar 2006)
New Revision: 13830
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=13830
Log:
When POSIX unlocking remember to cope with unlocking
the last lock.
Jeremy.
Modified:
trunk/source/locking/brlock.c
Changeset:
Modified: trunk/source/locking/brlock.c
===================================================================
--- trunk/source/locking/brlock.c 2006-03-04 00:05:40 UTC (rev 13829)
+++ trunk/source/locking/brlock.c 2006-03-04 00:16:51 UTC (rev 13830)
@@ -67,6 +67,26 @@
static TDB_CONTEXT *tdb;
/****************************************************************************
+ Debug info at level 10 for lock struct.
+****************************************************************************/
+
+static void print_lock_struct(unsigned int i, struct lock_struct *pls)
+{
+ DEBUG(10,("[%u]: smbpid = %u, tid = %u, pid = %u, ",
+ i,
+ (unsigned int)pls->context.smbpid,
+ (unsigned int)pls->context.tid,
+ (unsigned int)procid_to_pid(&pls->context.pid) ));
+
+ DEBUG(10,("start = %.0f, size = %.0f, fnum = %d, %s %s\n",
+ (double)pls->start,
+ (double)pls->size,
+ pls->fnum,
+ lock_type_name(pls->lock_type),
+ lock_flav_name(pls->lock_flav) ));
+}
+
+/****************************************************************************
Create a locking key - ensuring zero filled for pad purposes.
****************************************************************************/
@@ -811,6 +831,7 @@
/* Don't allow 64-bit lock wrap. */
if (plock->start + plock->size < plock->start ||
plock->start + plock->size < plock->size) {
+ DEBUG(10,("brl_unlock_posix: lock wrap\n"));
return False;
}
@@ -820,6 +841,7 @@
tp = SMB_MALLOC_ARRAY(struct lock_struct, (br_lck->num_locks + 1));
if (!tp) {
+ DEBUG(10,("brl_unlock_posix: malloc fail\n"));
return False;
}
@@ -898,6 +920,7 @@
if (!overlap_found) {
/* Just ignore - no change. */
SAFE_FREE(tp);
+ DEBUG(10,("brl_unlock_posix: No overlap - unlocked.\n"));
return True;
}
@@ -907,10 +930,18 @@
}
/* Realloc so we don't leak entries per unlock call. */
- tp1 = (struct lock_struct *)SMB_REALLOC(tp, count * sizeof(*locks));
- if (!tp1) {
- return False;
+ if (count) {
+ tp1 = (struct lock_struct *)SMB_REALLOC(tp, count * sizeof(*locks));
+ if (!tp1) {
+ DEBUG(10,("brl_unlock_posix: realloc fail\n"));
+ return False;
+ }
+ } else {
+ /* We deleted the last lock. */
+ SAFE_FREE(tp);
+ tp1 = NULL;
}
+
br_lck->num_locks = count;
br_lck->lock_data = (void *)tp1;
br_lck->modified = True;
@@ -1204,22 +1235,6 @@
return 0;
}
-static void print_lock_struct(unsigned int i, struct lock_struct *pls)
-{
- DEBUG(10,("[%u]: smbpid = %u, tid = %u, pid = %u, ",
- i,
- (unsigned int)pls->context.smbpid,
- (unsigned int)pls->context.tid,
- (unsigned int)procid_to_pid(&pls->context.pid) ));
-
- DEBUG(10,("start = %.0f, size = %.0f, fnum = %d, %s %s\n",
- (double)pls->start,
- (double)pls->size,
- pls->fnum,
- lock_type_name(pls->lock_type),
- lock_flav_name(pls->lock_flav) ));
-}
-
/*******************************************************************
Fetch a set of byte range lock data from the database.
Leave the record locked.
More information about the samba-cvs
mailing list