diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-03-31 23:03:46 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:35:13 -0700 |
commit | e5a2989efbae81f40b60885a8f92ea1f87df7ea9 (patch) | |
tree | e23fdb064f57cdaa9a48527c30ac5d877d32d924 /udevsend.c | |
parent | f27125f98f6487e881a957726da895aebd799f0d (diff) |
[PATCH] udevd race conditions and performance, assorted cleanups - take 2
here is a patch on top of your nice improvements.
I fixed the whitespace and it hopefully fixes the stupid timestamp bug in
udevd. Some stupid OS sets the hwclock to localtime and linux changes it
to UTC while starting. If any events are pending they may be delayed by
the users time distance from UTC :) So we use the uptime seconds now.
Diffstat (limited to 'udevsend.c')
-rw-r--r-- | udevsend.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/udevsend.c b/udevsend.c index f1c46d3367..f28e445433 100644 --- a/udevsend.c +++ b/udevsend.c @@ -26,13 +26,13 @@ #include <sys/socket.h> #include <sys/wait.h> #include <sys/un.h> +#include <time.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include <unistd.h> -#include <time.h> #include <linux/stddef.h> #include "udev.h" @@ -53,16 +53,15 @@ void log_message (int level, const char *format, ...) } #endif -static int build_hotplugmsg(struct hotplug_msg *msg, char *action, - char *devpath, char *subsystem, int seqnum) +static void build_hotplugmsg(struct hotplug_msg *msg, char *action, + char *devpath, char *subsystem, int seqnum) { - memset(msg, 0x00, sizeof(*msg)); + memset(msg, 0x00, sizeof(struct hotplug_msg)); strfieldcpy(msg->magic, UDEV_MAGIC); msg->seqnum = seqnum; strfieldcpy(msg->action, action); strfieldcpy(msg->devpath, devpath); strfieldcpy(msg->subsystem, subsystem); - return sizeof(struct hotplug_msg); } static int start_daemon(void) @@ -108,7 +107,6 @@ int main(int argc, char* argv[]) char *seqnum; int seq; int retval = 1; - int size; int loop; struct timespec tspec; int sock; @@ -155,18 +153,19 @@ int main(int argc, char* argv[]) goto exit; } - memset(&saddr, 0x00, sizeof(saddr)); + memset(&saddr, 0x00, sizeof(struct sockaddr_un)); saddr.sun_family = AF_LOCAL; /* 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; - size = build_hotplugmsg(&msg, action, devpath, subsystem, seq); + build_hotplugmsg(&msg, action, devpath, subsystem, seq); /* If we can't send, try to start daemon and resend message */ loop = UDEVSEND_CONNECT_RETRY; while (loop--) { - retval = sendto(sock, &msg, size, 0, (struct sockaddr *)&saddr, addrlen); + retval = sendto(sock, &msg, sizeof(struct hotplug_msg), 0, + (struct sockaddr *)&saddr, addrlen); if (retval != -1) { retval = 0; goto close_and_exit; |