mirror of
https://github.com/systemd/systemd.git
synced 2025-01-18 10:04:04 +03:00
sd-device-monitor: unconditionally increase buffer size by sd_device_monitor_new()
As suggested at https://github.com/systemd/systemd/pull/29872#discussion_r1382932633: > socket memory is these days accounted to the process that owns a socket, > hence we shouldn't be too concerned that this might waste memory.
This commit is contained in:
parent
7dafeb6d6b
commit
eba449fa81
@ -1028,11 +1028,6 @@ static void device_enumerate(Manager *m) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* This will fail if we are unprivileged, but that
|
||||
* should not matter much, as user instances won't run
|
||||
* during boot. */
|
||||
(void) sd_device_monitor_set_receive_buffer_size(m->device_monitor, 128*1024*1024);
|
||||
|
||||
r = sd_device_monitor_filter_add_match_tag(m->device_monitor, "systemd");
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to add udev tag match: %m");
|
||||
|
@ -215,6 +215,15 @@ int device_monitor_new_full(sd_device_monitor **ret, MonitorNetlinkGroup group,
|
||||
}
|
||||
}
|
||||
|
||||
/* Let's bump the receive buffer size, but only if we are not called via socket activation, as in
|
||||
* that case the service manager sets the receive buffer size for us, and the value in the .socket
|
||||
* unit should take full effect. */
|
||||
if (fd < 0) {
|
||||
r = sd_device_monitor_set_receive_buffer_size(m, 128*1024*1024);
|
||||
if (r < 0)
|
||||
log_monitor_errno(m, r, "Failed to increase receive buffer size, ignoring: %m");
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(m);
|
||||
return 0;
|
||||
|
||||
|
@ -205,10 +205,6 @@ static int manager_connect_udev(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize device monitor: %m");
|
||||
|
||||
r = sd_device_monitor_set_receive_buffer_size(m->device_monitor, RCVBUF_SIZE);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to increase buffer size for device monitor, ignoring: %m");
|
||||
|
||||
r = sd_device_monitor_filter_add_match_subsystem_devtype(m->device_monitor, "net", NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not add device monitor filter for net subsystem: %m");
|
||||
|
@ -1225,15 +1225,6 @@ int manager_init(Manager *manager, int fd_ctrl, int fd_uevent) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to initialize device monitor: %m");
|
||||
|
||||
/* Bump receiver buffer, but only if we are not called via socket activation, as in that
|
||||
* case systemd sets the receive buffer size for us, and the value in the .socket unit
|
||||
* should take full effect. */
|
||||
if (fd_uevent < 0) {
|
||||
r = sd_device_monitor_set_receive_buffer_size(manager->monitor, 128 * 1024 * 1024);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to set receive buffer size for device monitor, ignoring: %m");
|
||||
}
|
||||
|
||||
(void) sd_device_monitor_set_description(manager->monitor, "manager");
|
||||
|
||||
r = device_monitor_enable_receiving(manager->monitor);
|
||||
|
@ -66,8 +66,6 @@ static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create netlink socket: %m");
|
||||
|
||||
(void) sd_device_monitor_set_receive_buffer_size(monitor, 128*1024*1024);
|
||||
|
||||
r = sd_device_monitor_attach_event(monitor, event);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach event: %m");
|
||||
|
@ -526,8 +526,6 @@ int trigger_main(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create device monitor object: %m");
|
||||
|
||||
(void) sd_device_monitor_set_receive_buffer_size(m, 128*1024*1024);
|
||||
|
||||
r = sd_device_monitor_attach_event(m, event);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach event to device monitor: %m");
|
||||
|
@ -184,8 +184,6 @@ static int setup_monitor(sd_event *event, MonitorNetlinkGroup group, const char
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) sd_device_monitor_set_receive_buffer_size(monitor, 128*1024*1024);
|
||||
|
||||
r = sd_device_monitor_attach_event(monitor, event);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user