chiark / gitweb /
[PATCH] udevd - switch socket path to abstract namespace
[elogind.git] / udevd.c
diff --git a/udevd.c b/udevd.c
index dc7d581c242e798b03d6071619446b1c61fe35f8..24cf9c9a7cf8c5a491c63483fff09f4a91455b70 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -42,6 +42,7 @@
 #include "logging.h"
 
 
+unsigned char logname[42];
 static pthread_mutex_t  msg_lock;
 static pthread_mutex_t  msg_active_lock;
 static pthread_cond_t msg_active;
@@ -204,16 +205,20 @@ static void *exec_queue_manager(void * parm)
        }
 }
 
-/* move message from incoming to exec queue */
-static void msg_move_exec(struct list_head *head)
+static void exec_queue_activate(void)
 {
-       list_move_tail(head, &exec_list);
-       /* signal queue activity to manager */
        pthread_mutex_lock(&exec_active_lock);
        pthread_cond_signal(&exec_active);
        pthread_mutex_unlock(&exec_active_lock);
 }
 
+/* move message from incoming to exec queue */
+static void msg_move_exec(struct list_head *head)
+{
+       list_move_tail(head, &exec_list);
+       exec_queue_activate();
+}
+
 /* queue management thread handles the timeouts and dispatches the events */
 static void *msg_queue_manager(void * parm)
 {
@@ -297,9 +302,17 @@ static void *client_threads(void * parm)
                goto exit;
        }
 
-       pthread_mutex_lock(&msg_lock);
-       msg_queue_insert(msg);
-       pthread_mutex_unlock(&msg_lock);
+       /* if no seqnum is given, we move straight to exec queue */
+       if (msg->seqnum == 0) {
+               pthread_mutex_lock(&exec_lock);
+               list_add(&msg->list, &exec_list);
+               exec_queue_activate();
+               pthread_mutex_unlock(&exec_lock);
+       } else {
+               pthread_mutex_lock(&msg_lock);
+               msg_queue_insert(msg);
+               pthread_mutex_unlock(&msg_lock);
+       }
 
 exit:
        close(sock);
@@ -312,7 +325,6 @@ static void sig_handler(int signum)
                case SIGINT:
                case SIGTERM:
                        unlink(UDEVD_LOCK);
-                       unlink(UDEVD_SOCK);
                        exit(20 + signum);
                        break;
                default:
@@ -354,6 +366,8 @@ int main(int argc, char *argv[])
        pthread_t mgr_exec_tid;
        int retval;
 
+       init_logging("udevd");
+
        /* only let one version of the daemon run at any one time */
        if (one_and_only() != 0)
                exit(0);
@@ -363,9 +377,9 @@ int main(int argc, char *argv[])
 
        memset(&saddr, 0x00, sizeof(saddr));
        saddr.sun_family = AF_LOCAL;
-       strcpy(saddr.sun_path, UDEVD_SOCK);
+       /* use abstract namespace for socket path */
+       strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
 
-       unlink(UDEVD_SOCK);
        ssock = socket(AF_LOCAL, SOCK_STREAM, 0);
        if (ssock == -1) {
                dbg("error getting socket");
@@ -411,6 +425,5 @@ int main(int argc, char *argv[])
        }
 exit:
        close(ssock);
-       unlink(UDEVD_SOCK);
        exit(1);
 }