email plugin: Kill threads before closing the associated socket
authorSebastian Harl <sh@tokkee.org>
Tue, 12 Dec 2006 09:50:12 +0000 (10:50 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Wed, 13 Dec 2006 07:01:08 +0000 (08:01 +0100)
If the socket is closed before the thread is terminated it might cause some
confusing error messages if the thread wants to read from the socket.

Signed-off-by: Sebastian Harl <sh@tokkee.org>
src/email.c

index 377a6b1..0f9c2f3 100644 (file)
@@ -685,15 +685,15 @@ static void email_shutdown (void)
        if (disabled)
                return;
 
-       close (connector_socket);
        pthread_kill (connector, SIGTERM);
+       close (connector_socket);
 
        /* don't allow any more connections to be processed */
        pthread_mutex_lock (&conns_mutex);
 
        for (i = 0; i < max_conns; ++i) {
-               close (collectors[i]->socket);
                pthread_kill (collectors[i]->thread, SIGTERM);
+               close (collectors[i]->socket);
        }
 
        pthread_mutex_unlock (&conns_mutex);