From c2bb4b51c1e660a675197063781323fe65c97135 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 8 Apr 2008 15:19:01 +0400 Subject: Destroy DMAPI session when main smbd daemon exits. DMAPI session is precious resource maintained at kernel level. We open one of them and use across multiple smbd daemons but once last of them exits, DMAPI session needs to be destroyed. There are some HSM implementations which fail to shutdown when opened DMAPI sessions left. Ensure we shutdown our session when it is really not needed anymore. This is what recommended by DMAPI specification anyway. (This used to be commit a0cefd44009d414fa00ec6e08c70d21b74acdbcb) --- source3/smbd/dmapi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source3/smbd/dmapi.c') 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 @@ -212,6 +212,30 @@ bool dmapi_new_session(void) return samba_dmapi_session != DM_NO_SESSION; } +/* + 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. -- cgit