svn commit: samba r5732 - in trunk/source: include smbd

jra at samba.org jra at samba.org
Thu Mar 10 21:44:12 GMT 2005


Author: jra
Date: 2005-03-10 21:44:11 +0000 (Thu, 10 Mar 2005)
New Revision: 5732

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

Log:
Get delayed write semantics closer to W2K3. We need to store 2 times.
This may fix bug #2382.
Jeremy.

Modified:
   trunk/source/include/smb.h
   trunk/source/smbd/close.c
   trunk/source/smbd/fileio.c
   trunk/source/smbd/files.c


Changeset:
Modified: trunk/source/include/smb.h
===================================================================
--- trunk/source/include/smb.h	2005-03-10 21:43:58 UTC (rev 5731)
+++ trunk/source/include/smb.h	2005-03-10 21:44:11 UTC (rev 5732)
@@ -410,7 +410,9 @@
 	struct timeval open_time;
 	int share_mode;
 	uint32 desired_access;
+	BOOL pending_modtime_owner;
 	time_t pending_modtime;
+	time_t last_write_time;
 	int oplock_type;
 	int sent_oplock_break;
 	unsigned long file_id;

Modified: trunk/source/smbd/close.c
===================================================================
--- trunk/source/smbd/close.c	2005-03-10 21:43:58 UTC (rev 5731)
+++ trunk/source/smbd/close.c	2005-03-10 21:44:11 UTC (rev 5732)
@@ -260,8 +260,10 @@
 	 * Ensure pending modtime is set after close.
 	 */
 
-	if(fsp->pending_modtime) {
+	if(fsp->pending_modtime && fsp->pending_modtime_owner) {
 		set_filetime(conn, fsp->fsp_name, fsp->pending_modtime);
+	} else if (fsp->last_write_time) {
+		set_filetime(conn, fsp->fsp_name, fsp->last_write_time);
 	}
 
 	DEBUG(2,("%s closed file %s (numopen=%d) %s\n",

Modified: trunk/source/smbd/fileio.c
===================================================================
--- trunk/source/smbd/fileio.c	2005-03-10 21:43:58 UTC (rev 5731)
+++ trunk/source/smbd/fileio.c	2005-03-10 21:44:11 UTC (rev 5732)
@@ -142,6 +142,12 @@
 
 		if (fsp->pending_modtime) {
 			set_filetime(fsp->conn, fsp->fsp_name, fsp->pending_modtime);
+
+			/* If we didn't get the "set modtime" call ourselves, we must
+			   store the last write time to restore on close. JRA. */
+			if (!fsp->pending_modtime_owner) {
+				fsp->last_write_time = time(NULL);
+			}
 		}
 
 /* Yes - this is correct - writes don't update this. JRA. */

Modified: trunk/source/smbd/files.c
===================================================================
--- trunk/source/smbd/files.c	2005-03-10 21:43:58 UTC (rev 5731)
+++ trunk/source/smbd/files.c	2005-03-10 21:44:11 UTC (rev 5732)
@@ -379,6 +379,7 @@
 
 /****************************************************************************
  Set a pending modtime across all files with a given dev/ino pair.
+ Record the owner of that modtime.
 ****************************************************************************/
 
 void fsp_set_pending_modtime(files_struct *tfsp, time_t pmod)
@@ -394,8 +395,11 @@
 				fsp->dev == tfsp->dev &&
 				fsp->inode == tfsp->inode ) {
 			fsp->pending_modtime = pmod;
+			fsp->pending_modtime_owner = False;
 		}
 	}
+
+	tfsp->pending_modtime_owner = True;
 }
 
 /****************************************************************************



More information about the samba-cvs mailing list