s3:smbd: reorder tcon global record deletion and closing files of a tcon
authorRalph Boehme <slow@samba.org>
Thu, 30 Aug 2018 13:50:02 +0000 (15:50 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 31 Aug 2018 20:22:23 +0000 (22:22 +0200)
As such, this doesn't change overall behaviour, but in case we ever add
semantics acting on tcon record changes via an API like
dbwrap_watch_send(), this will make a difference as it enforces
ordering.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13549

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smbXsrv_tcon.c

index eb483937d63c7cf01f6c66c91ed1d23b329ffd37..ded4010f5da6f4cc62e057e239d815377ce70fad 100644 (file)
@@ -904,6 +904,25 @@ NTSTATUS smbXsrv_tcon_disconnect(struct smbXsrv_tcon *tcon, uint64_t vuid)
        table = tcon->table;
        tcon->table = NULL;
 
+       if (tcon->compat) {
+               bool ok;
+
+               ok = chdir_current_service(tcon->compat);
+               if (!ok) {
+                       status = NT_STATUS_INTERNAL_ERROR;
+                       DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): "
+                                 "chdir_current_service() failed: %s\n",
+                                 tcon->global->tcon_global_id,
+                                 tcon->global->share_name,
+                                 nt_errstr(status)));
+                       tcon->compat = NULL;
+                       return status;
+               }
+
+               close_cnum(tcon->compat, vuid);
+               tcon->compat = NULL;
+       }
+
        tcon->status = NT_STATUS_NETWORK_NAME_DELETED;
 
        global_rec = tcon->global->db_rec;
@@ -966,25 +985,6 @@ NTSTATUS smbXsrv_tcon_disconnect(struct smbXsrv_tcon *tcon, uint64_t vuid)
        }
        tcon->db_rec = NULL;
 
-       if (tcon->compat) {
-               bool ok;
-
-               ok = chdir_current_service(tcon->compat);
-               if (!ok) {
-                       status = NT_STATUS_INTERNAL_ERROR;
-                       DEBUG(0, ("smbXsrv_tcon_disconnect(0x%08x, '%s'): "
-                                 "chdir_current_service() failed: %s\n",
-                                 tcon->global->tcon_global_id,
-                                 tcon->global->share_name,
-                                 nt_errstr(status)));
-                       tcon->compat = NULL;
-                       return status;
-               }
-
-               close_cnum(tcon->compat, vuid);
-               tcon->compat = NULL;
-       }
-
        return error;
 }