ensure we exit with non-zero status on EOF on socket, so the parent
authorAndrew Tridgell <tridge@samba.org>
Fri, 8 Aug 2008 12:34:59 +0000 (22:34 +1000)
committerMichael Adam <obnox@samba.org>
Wed, 13 Aug 2008 09:54:12 +0000 (11:54 +0200)
can trigger a brlock db cleanup
(This used to be commit bbd49f9e1c4b50c4a596fb991f3306e1e90c0177)

source3/smbd/conn.c
source3/smbd/server.c

index 1a67ac9b3223b55a130aca77da2d0e57a8c46eca..b9433bb96580385a7312efe1e2afec17dc2941de 100644 (file)
@@ -161,16 +161,19 @@ find_again:
 
 /****************************************************************************
  Close all conn structures.
+return true if any were closed
 ****************************************************************************/
-
-void conn_close_all(void)
+bool conn_close_all(void)
 {
        connection_struct *conn, *next;
+       bool ret = false;
        for (conn=Connections;conn;conn=next) {
                next=conn->next;
                set_current_service(conn, 0, True);
                close_cnum(conn, conn->vuid);
+               ret = true;
        }
+       return ret;
 }
 
 /****************************************************************************
index 265d4927f58c9374799f191333c89078ff683879..c7bf1daf684ce5ff3e1517e3c305579ca7af24dd 100644 (file)
@@ -296,7 +296,7 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown)
                /* a child terminated uncleanly so tickle all processes to see 
                   if they can grab any of the pending locks
                */
-               DEBUG(0,(__location__ " Unclean shutdown of pid %u\n", pid));
+               DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", pid));
                messaging_send_buf(smbd_messaging_context(), procid_self(), 
                                   MSG_SMB_BRL_VALIDATE, NULL, 0);
                message_send_all(smbd_messaging_context(), 
@@ -891,6 +891,7 @@ static void exit_server_common(enum server_exit_reason how,
        const char *const reason)
 {
        static int firsttime=1;
+       bool had_open_conn;
 
        if (!firsttime)
                exit(0);
@@ -902,7 +903,7 @@ static void exit_server_common(enum server_exit_reason how,
                (negprot_global_auth_context->free)(&negprot_global_auth_context);
        }
 
-       conn_close_all();
+       had_open_conn = conn_close_all();
 
        invalidate_all_vuids();
 
@@ -952,7 +953,11 @@ static void exit_server_common(enum server_exit_reason how,
                        (reason ? reason : "normal exit")));
        }
 
-       exit(0);
+       if (had_open_conn) {
+               exit(1);
+       } else {
+               exit(0);
+       }
 }
 
 void exit_server(const char *const explanation)