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.
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");
}
}
+ /* 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;
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");
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);
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");
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");
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;