Author: vlendec
Date: 2005-08-23 20:46:10 +0000 (Tue, 23 Aug 2005)
New Revision: 9542

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

Log:
If someone writes to a file with level2 opens around, these are notified. At
the same time this notification is written down in the share mode db. This
leads to an accepted discrapency between fsp->oplock_type and locking.tdb. Fix
validate_my_share_entries accordingly. release_level_2_oplocks_on_change does
not need to send around messages either if this has happened.

Volker

Modified:
   trunk/source/smbd/open.c
   trunk/source/smbd/oplock.c


Changeset:
Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c    2005-08-23 20:23:43 UTC (rev 9541)
+++ trunk/source/smbd/open.c    2005-08-23 20:46:10 UTC (rev 9542)
@@ -492,6 +492,13 @@
                          "share entry with an open file\n");
        }
 
+       if ((share_entry->op_type == NO_OPLOCK) &&
+           (fsp->oplock_type == FAKE_LEVEL_II_OPLOCK)) {
+               /* Someone has already written to it, but I haven't yet
+                * noticed */
+               return;
+       }
+
        if (((uint16)fsp->oplock_type) != share_entry->op_type) {
                pstring str;
                DEBUG(0,("validate_my_share_entries: PANIC : %s\n",

Modified: trunk/source/smbd/oplock.c
===================================================================
--- trunk/source/smbd/oplock.c  2005-08-23 20:23:43 UTC (rev 9541)
+++ trunk/source/smbd/oplock.c  2005-08-23 20:46:10 UTC (rev 9542)
@@ -633,6 +633,24 @@
        DEBUG(10,("release_level_2_oplocks_on_change: num_share_modes = %d\n", 
                        num_share_modes ));
 
+       if (fsp->oplock_type == FAKE_LEVEL_II_OPLOCK) {
+               /* See if someone else has already downgraded us, then we
+                  don't have to do anything */
+               for (i=0; i<num_share_modes; i++) {
+                       if ((share_list[i].op_type == NO_OPLOCK) &&
+                           (share_list[i].share_file_id == fsp->file_id) &&
+                           (share_list[i].dev == fsp->dev) &&
+                           (share_list[i].inode == fsp->inode) &&
+                           (share_list[i].pid == sys_getpid())) {
+                               /* We're done */
+                               fsp->oplock_type = NO_OPLOCK;
+                               SAFE_FREE(share_list);
+                               unlock_share_entry_fsp(fsp);
+                               return;
+                       }
+               }
+       }
+
        for(i = 0; i < num_share_modes; i++) {
                share_mode_entry *share_entry = &share_list[i];
 

Reply via email to