From: Kay Sievers Date: Fri, 17 Oct 2008 14:49:27 +0000 (+0200) Subject: libudev: monitor - add set_receive_buffer_size() X-Git-Tag: 174~1429 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb25a9585d87d8dd13d9eae66fd232e3dfdc8fac;p=systemd libudev: monitor - add set_receive_buffer_size() --- diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c index d0f28849..6c6f4aa7 100644 --- a/udev/lib/libudev-monitor.c +++ b/udev/lib/libudev-monitor.c @@ -152,6 +152,13 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor) return 0; } +int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size) +{ + if (udev_monitor == NULL) + return -1; + return setsockopt(udev_monitor->sock, SOL_SOCKET, SO_RCVBUFFORCE, &size, sizeof(size)); +} + /** * udev_monitor_ref: * @udev_monitor: udev monitor diff --git a/udev/lib/libudev-private.h b/udev/lib/libudev-private.h index f2814c4a..50c96571 100644 --- a/udev/lib/libudev-private.h +++ b/udev/lib/libudev-private.h @@ -91,6 +91,7 @@ extern int udev_device_rename_db(struct udev_device *udev_device, const char *de /* libudev-monitor - netlink/unix socket communication */ extern int udev_monitor_send_device(struct udev_monitor *udev_monitor, struct udev_device *udev_device); +extern int udev_monitor_set_receive_buffer_size(struct udev_monitor *udev_monitor, int size); /* libudev-ctrl - daemon runtime setup */ struct udev_ctrl; diff --git a/udev/udevd.c b/udev/udevd.c index 1583e22a..0c82e56d 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -24,15 +24,11 @@ #include #include #include -#include #include -#include #include #include #include #include -#include -#include #include #include #ifdef HAVE_INOTIFY @@ -213,7 +209,7 @@ static void event_fork(struct udev_event *event) /* execute RUN= */ if (err == 0 && !event->ignore_device && udev_get_run(event->udev)) udev_rules_run(event); - info(event->udev, "seq %llu finished with %i\n", udev_device_get_seqnum(event->dev), err); + info(event->udev, "seq %llu exit with %i\n", udev_device_get_seqnum(event->dev), err); logging_close(); if (err != 0) exit(1); @@ -242,7 +238,8 @@ static void event_queue_insert(struct udev_event *event) event->queue_time = time(NULL); export_event_state(event, EVENT_QUEUED); - info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(event->dev), udev_device_get_action(event->dev), udev_device_get_subsystem(event->dev)); + info(event->udev, "seq %llu queued, '%s' '%s'\n", udev_device_get_seqnum(event->dev), + udev_device_get_action(event->dev), udev_device_get_subsystem(event->dev)); util_strlcpy(filename, udev_get_dev_path(event->udev), sizeof(filename)); util_strlcat(filename, "/.udev/uevent_seqnum", sizeof(filename)); @@ -545,7 +542,7 @@ static void udev_done(int pid, int exitstatus) list_for_each_entry(event, &running_list, node) { if (event->pid == pid) { - info(event->udev, "seq %llu, pid [%d] exit with %i, %ld seconds old\n", + info(event->udev, "seq %llu cleanup, pid [%d], status %i, %ld seconds old\n", udev_device_get_seqnum(event->dev), event->pid, exitstatus, time(NULL) - event->queue_time); event->exitstatus = exitstatus; @@ -705,13 +702,8 @@ int main(int argc, char *argv[]) err(udev, "error initializing netlink socket\n"); rc = 3; goto exit; - } else { - /* set receive buffersize */ - const int buffersize = 32 * 1024 * 1024; - - setsockopt(udev_monitor_get_fd(kernel_monitor), - SOL_SOCKET, SO_RCVBUFFORCE, &buffersize, sizeof(buffersize)); } + udev_monitor_set_receive_buffer_size(kernel_monitor, 128*1024*1024); err = pipe(signal_pipe); if (err < 0) { @@ -860,7 +852,6 @@ int main(int argc, char *argv[]) maxfd = UDEV_MAX(maxfd, udev_monitor_get_fd(kernel_monitor)); maxfd = UDEV_MAX(maxfd, signal_pipe[READ_END]); maxfd = UDEV_MAX(maxfd, inotify_fd); - while (!udev_exit) { int fdcount; @@ -870,7 +861,6 @@ int main(int argc, char *argv[]) FD_SET(udev_monitor_get_fd(kernel_monitor), &readfds); if (inotify_fd >= 0) FD_SET(inotify_fd, &readfds); - fdcount = select(maxfd+1, &readfds, NULL, NULL, NULL); if (fdcount < 0) { if (errno != EINTR)