svn commit: samba r14761 - in trunk/source: locking smbd

jra at samba.org jra at samba.org
Wed Mar 29 19:40:40 GMT 2006


Author: jra
Date: 2006-03-29 19:40:39 +0000 (Wed, 29 Mar 2006)
New Revision: 14761

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

Log:
Pass in extra parameters which will make it easier
to do blocking POSIX lock requests.
Jeremy.

Modified:
   trunk/source/locking/brlock.c
   trunk/source/smbd/blocking.c
   trunk/source/smbd/reply.c


Changeset:
Modified: trunk/source/locking/brlock.c
===================================================================
--- trunk/source/locking/brlock.c	2006-03-29 18:55:39 UTC (rev 14760)
+++ trunk/source/locking/brlock.c	2006-03-29 19:40:39 UTC (rev 14761)
@@ -189,7 +189,7 @@
 		return False;
 	}
 
-	/* One is read, the other write, context or fnum are different,
+	/* One is read, the other write, or the context is different,
 	   do they overlap ? */
 	return brl_overlap(lck1, lck2);
 } 

Modified: trunk/source/smbd/blocking.c
===================================================================
--- trunk/source/smbd/blocking.c	2006-03-29 18:55:39 UTC (rev 14760)
+++ trunk/source/smbd/blocking.c	2006-03-29 19:40:39 UTC (rev 14761)
@@ -36,6 +36,7 @@
 	SMB_BIG_UINT count;
 	uint16 lock_pid;
 	enum brl_flavour lock_flav;
+	enum brl_type lock_type;
 	char *inbuf;
 	int length;
 } blocking_lock_record;
@@ -54,25 +55,6 @@
 }
 
 /****************************************************************************
- Get the files_struct given a particular queued SMB.
-*****************************************************************************/
-
-static files_struct *get_fsp_from_pkt(char *inbuf)
-{
-	switch(CVAL(inbuf,smb_com)) {
-		case SMBlock:
-		case SMBlockread:
-			return file_fsp(inbuf,smb_vwv0);
-		case SMBlockingX:
-			return file_fsp(inbuf,smb_vwv2);
-		default:
-			DEBUG(0,("get_fsp_from_pkt: PANIC - unknown type on blocking lock queue - exiting.!\n"));
-			exit_server("PANIC - unknown type on blocking lock queue");
-	}
-	return NULL; /* Keep compiler happy. */
-}
-
-/****************************************************************************
  Determine if this is a secondary element of a chained SMB.
   **************************************************************************/
 
@@ -88,8 +70,14 @@
  Function to push a blocking lock request onto the lock queue.
 ****************************************************************************/
 
-BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout,
-		int lock_num, uint16 lock_pid, SMB_BIG_UINT offset, SMB_BIG_UINT count)
+BOOL push_blocking_lock_request( char *inbuf, int length,
+		files_struct *fsp,
+		int lock_timeout,
+		int lock_num,
+		uint16 lock_pid,
+		enum brl_type lock_type,
+		enum brl_flavour lock_flav,
+		SMB_BIG_UINT offset, SMB_BIG_UINT count)
 {
 	static BOOL set_lock_msg;
 	blocking_lock_record *blr, *tmp;
@@ -119,11 +107,12 @@
 	}
 
 	blr->com_type = CVAL(inbuf,smb_com);
-	blr->fsp = get_fsp_from_pkt(inbuf);
+	blr->fsp = fsp;
 	blr->expire_time = (lock_timeout == -1) ? (time_t)-1 : time(NULL) + (time_t)lock_timeout;
 	blr->lock_num = lock_num;
 	blr->lock_pid = lock_pid;
-	blr->lock_flav = WINDOWS_LOCK;
+	blr->lock_flav = lock_flav;
+	blr->lock_type = lock_type;
 	blr->offset = offset;
 	blr->count = count;
 	memcpy(blr->inbuf, inbuf, length);

Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c	2006-03-29 18:55:39 UTC (rev 14760)
+++ trunk/source/smbd/reply.c	2006-03-29 19:40:39 UTC (rev 14761)
@@ -2412,8 +2412,15 @@
 			 * this smb into a queued request and push it
 			 * onto the blocking lock queue.
 			 */
-			if(push_blocking_lock_request(inbuf, length, -1, 0, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)startpos,
-								(SMB_BIG_UINT)numtoread)) {
+			if(push_blocking_lock_request(inbuf, length,
+					fsp,
+					-1,
+					0,
+					SVAL(inbuf,smb_pid),
+					WRITE_LOCK,
+					WINDOWS_LOCK,
+					(SMB_BIG_UINT)startpos,
+					(SMB_BIG_UINT)numtoread)) {
 				END_PROFILE(SMBlockread);
 				return -1;
 			}
@@ -3435,7 +3442,14 @@
 			 * this smb into a queued request and push it
 			 * onto the blocking lock queue.
 			 */
-			if(push_blocking_lock_request(inbuf, length, -1, 0, SVAL(inbuf,smb_pid), offset, count)) {
+			if(push_blocking_lock_request(inbuf, length,
+				fsp,
+				-1,
+				0,
+				SVAL(inbuf,smb_pid),
+				WRITE_LOCK,
+				WINDOWS_LOCK,
+				offset, count)) {
 				END_PROFILE(SMBlock);
 				return -1;
 			}
@@ -5322,6 +5336,7 @@
 	   of smb_lkrng structs */
 	
 	for(i = 0; i < (int)num_locks; i++) {
+		enum brl_type lock_type = ((locktype & 1) ? READ_LOCK:WRITE_LOCK);
 		lock_pid = get_lock_pid( data, i, large_file_format);
 		count = get_lock_count( data, i, large_file_format);
 		offset = get_lock_offset( data, i, large_file_format, &err);
@@ -5343,7 +5358,7 @@
 					lock_pid,
 					count,
 					offset, 
-					((locktype & 1) ? READ_LOCK:WRITE_LOCK),
+					lock_type,
 					WINDOWS_LOCK,
 					&my_lock_ctx);
 
@@ -5364,8 +5379,13 @@
 				 * onto the blocking lock queue.
 				 */
 				if(push_blocking_lock_request(inbuf, length,
-							      lock_timeout, i,
-							      lock_pid, offset,
+							      fsp,
+							      lock_timeout,
+						 	      i,
+							      lock_pid,
+							      lock_type,
+							      WINDOWS_LOCK,
+							      offset,
 							      count)) {
 					END_PROFILE(SMBlockingX);
 					return -1;



More information about the samba-cvs mailing list