summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/dmapi.c24
-rw-r--r--source3/smbd/server.c9
2 files changed, 33 insertions, 0 deletions
diff --git a/source3/smbd/dmapi.c b/source3/smbd/dmapi.c
index fab0d5f9ef..fd252e980a 100644
--- a/source3/smbd/dmapi.c
+++ b/source3/smbd/dmapi.c
@@ -213,6 +213,30 @@ bool dmapi_new_session(void)
}
/*
+ only call this when exiting from master smbd process. DMAPI sessions
+ are long-lived kernel resources we ought to share across smbd processes.
+ However, we must free them when all smbd processes are finished to
+ allow other subsystems clean up properly. Not freeing DMAPI session
+ blocks certain HSM implementations from proper shutdown.
+*/
+bool dmapi_destroy_session(void)
+{
+ if (samba_dmapi_session != DM_NO_SESSION) {
+ become_root();
+ if (!dm_destroy_session(samba_dmapi_session)) {
+ session_num--;
+ samba_dmapi_session = DM_NO_SESSION;
+ } else {
+ DEBUG(0,("Couldn't destroy DMAPI session: %s\n",
+ strerror(errno)));
+ }
+ unbecome_root();
+ }
+ return samba_dmapi_session == DM_NO_SESSION;
+}
+
+
+/*
This is default implementation of dmapi_file_flags() that is
called from VFS is_offline() call to know whether file is offline.
For GPFS-specific version see modules/vfs_tsmsm.c. It might be
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 179d480f43..7a6e17135f 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -918,6 +918,15 @@ static void exit_server_common(enum server_exit_reason how,
}
#endif
+#ifdef USE_DMAPI
+ /* Destroy Samba DMAPI session only if we are master smbd process */
+ if (am_parent) {
+ if (!dmapi_destroy_session()) {
+ DEBUG(0,("Unable to close Samba DMAPI session\n"));
+ }
+ }
+#endif
+
locking_end();
printing_end();