X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udevd.c;h=10d67f2c359995c861ecb94a554d855b14852b00;hb=1dadabd79b28a4cd72382abf746e9cf4c0589617;hp=331b7e4b84aa9d0229f709268dcbe58248e88701;hpb=95a6f4c8acafe7031087667aa556a50a6a091c93;p=elogind.git diff --git a/udevd.c b/udevd.c index 331b7e4b8..10d67f2c3 100644 --- a/udevd.c +++ b/udevd.c @@ -205,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) { @@ -298,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); @@ -313,7 +325,6 @@ static void sig_handler(int signum) case SIGINT: case SIGTERM: unlink(UDEVD_LOCK); - unlink(UDEVD_SOCK); exit(20 + signum); break; default: @@ -349,6 +360,7 @@ int main(int argc, char *argv[]) int csock; struct sockaddr_un saddr; struct sockaddr_un caddr; + socklen_t addrlen; socklen_t clen; pthread_t cli_tid; pthread_t mgr_msg_tid; @@ -366,16 +378,17 @@ 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); + addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1; - unlink(UDEVD_SOCK); ssock = socket(AF_LOCAL, SOCK_STREAM, 0); if (ssock == -1) { dbg("error getting socket"); exit(1); } - retval = bind(ssock, &saddr, sizeof(saddr)); + retval = bind(ssock, &saddr, addrlen); if (retval < 0) { dbg("bind failed\n"); goto exit; @@ -414,6 +427,5 @@ int main(int argc, char *argv[]) } exit: close(ssock); - unlink(UDEVD_SOCK); exit(1); }