From: Lee Duncan <ldun...@suse.com>

The same code that is executed by iscsid
when iscsiadm sends the "immediate stop"
command should be executed when iscsid
receives a SIGTERM.

Signed-off-by: Lee Duncan <ldun...@suse.com>
---
 usr/iscsid.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/usr/iscsid.c b/usr/iscsid.c
index 0c2634448d09..c87e1e7a47ac 100644
--- a/usr/iscsid.c
+++ b/usr/iscsid.c
@@ -303,6 +303,20 @@ static void iscsid_shutdown(void)
        }
 }
 
+static void iscsid_shutdown_and_cleanup(void)
+{
+       idbm_terminate();
+       sysfs_cleanup();
+       ipc->ctldev_close();
+       mgmt_ipc_close(mgmt_ipc_fd);
+       if (daemon_config.initiator_name)
+               free(daemon_config.initiator_name);
+       if (daemon_config.initiator_alias)
+               free(daemon_config.initiator_alias);
+       free_initiator();
+       iscsid_shutdown();
+}
+
 static void catch_signal(int signo)
 {
        log_debug(1, "pid %d caught signal %d", getpid(), signo);
@@ -313,7 +327,7 @@ static void catch_signal(int signo)
 
        switch (signo) {
        case SIGTERM:
-               iscsid_shutdown();
+               iscsid_shutdown_and_cleanup();
                exit(0);
                break;
        default:
@@ -556,15 +570,6 @@ int main(int argc, char *argv[])
 
        event_loop(ipc, control_fd, mgmt_ipc_fd);
 
-       idbm_terminate();
-       sysfs_cleanup();
-       ipc->ctldev_close();
-       mgmt_ipc_close(mgmt_ipc_fd);
-       if (daemon_config.initiator_name)
-               free(daemon_config.initiator_name);
-       if (daemon_config.initiator_alias)
-               free(daemon_config.initiator_alias);
-       free_initiator();
-       iscsid_shutdown();
+       iscsid_shutdown_and_cleanup();
        return 0;
 }
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to