diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-17 16:49:27 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-17 16:49:27 +0200 |
commit | cb25a9585d87d8dd13d9eae66fd232e3dfdc8fac (patch) | |
tree | 386032c94090b61ec2be78c57f7ab68810d84a4c /udev | |
parent | d960ad1546548d4b7aaf35e8b8f2cef652449ee7 (diff) |
libudev: monitor - add set_receive_buffer_size()
Diffstat (limited to 'udev')
-rw-r--r-- | udev/lib/libudev-monitor.c | 7 | ||||
-rw-r--r-- | udev/lib/libudev-private.h | 1 | ||||
-rw-r--r-- | udev/udevd.c | 20 |
3 files changed, 13 insertions, 15 deletions
diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c index d0f28849aa..6c6f4aa7e0 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 f2814c4ad6..50c96571c5 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 1583e22ac9..0c82e56dc5 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -24,15 +24,11 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> -#include <dirent.h> #include <fcntl.h> -#include <syslog.h> #include <time.h> #include <getopt.h> #include <sys/select.h> #include <sys/wait.h> -#include <sys/types.h> -#include <sys/socket.h> #include <sys/stat.h> #include <sys/ioctl.h> #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) |