Index: server.c
===================================================================
--- server.c	(revision 2357)
+++ server.c	(working copy)
@@ -524,6 +524,8 @@
 static void *joblist_queue_thread(void *_data) {
 	server *srv = _data;
 
+	g_mutex_lock(joblist_queue_mutex);
+
 	while (!srv_shutdown) {
 		GTimeVal ts;
 		connection *con;
@@ -532,8 +534,6 @@
 		/* wait for getting signaled */
 
 		if (srv_shutdown) {
-			g_mutex_unlock(joblist_queue_mutex);
-
 			break;
 		}
 
@@ -558,10 +558,10 @@
 			/* interrupt the poll() */
 			if (killme) write(srv->wakeup_pipe[1], " ", 1);
 		}
-
-		g_mutex_unlock(joblist_queue_mutex);
 	}
 
+	g_mutex_unlock(joblist_queue_mutex);
+
 	return NULL;
 }
 #endif
