*
*/
+#include <pthread.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <pthread.h>
#include "list.h"
#include "udev.h"
#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;
msg->seqnum, msg->action, msg->devpath, msg->subsystem);
}
-/* allocates a new message */
static struct hotplug_msg *msg_create(void)
{
struct hotplug_msg *new_msg;
dbg("error malloc");
return NULL;
}
- memset(new_msg, 0x00, sizeof(struct hotplug_msg));
return new_msg;
}
+static void msg_delete(struct hotplug_msg *msg)
+{
+ if (msg != NULL)
+ free(msg);
+}
+
/* orders the message in the queue by sequence number */
static void msg_queue_insert(struct hotplug_msg *msg)
{
list_del_init(&msg->list);
pthread_mutex_unlock(&running_lock);
- free(msg);
+ msg_delete(msg);
/* signal queue activity to exec manager */
pthread_mutex_lock(&exec_active_lock);
if (strncmp(msg->magic, UDEV_MAGIC, sizeof(UDEV_MAGIC)) != 0 ) {
dbg("message magic '%s' doesn't match, ignore it", msg->magic);
+ msg_delete(msg);
goto exit;
}
case SIGINT:
case SIGTERM:
unlink(UDEVD_LOCK);
- unlink(UDEVD_SOCKET);
+ unlink(UDEVD_SOCK);
exit(20 + signum);
break;
default:
char string[50];
int lock_file;
- /* see if we can open */
lock_file = open(UDEVD_LOCK, O_RDWR | O_CREAT, 0x640);
if (lock_file < 0)
return -1;
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);
memset(&saddr, 0x00, sizeof(saddr));
saddr.sun_family = AF_LOCAL;
- strcpy(saddr.sun_path, UDEVD_SOCKET);
+ strcpy(saddr.sun_path, UDEVD_SOCK);
- unlink(UDEVD_SOCKET);
+ unlink(UDEVD_SOCK);
ssock = socket(AF_LOCAL, SOCK_STREAM, 0);
if (ssock == -1) {
dbg("error getting socket");
/* set default attributes for created threads */
pthread_attr_init(&thr_attr);
pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED);
+ pthread_attr_setstacksize(&thr_attr, 16 * 1024);
/* init queue management */
pthread_create(&mgr_msg_tid, &thr_attr, msg_queue_manager, NULL);
while (1) {
csock = accept(ssock, &caddr, &clen);
if (csock < 0) {
- if (errno == EINTR)
- continue;
dbg("client accept failed\n");
+ continue;
}
pthread_create(&cli_tid, &thr_attr, client_threads, (void *) csock);
}
exit:
close(ssock);
- unlink(UDEVD_SOCKET);
+ unlink(UDEVD_SOCK);
exit(1);
}