sd-device-monitor: fix ordering of setting buffer size

By b1c097af8d (#10239), the receive buffer
size for uevents was set by SO_RCVBUF at first, and fallback to
use SO_RCVBUFFORCE. So, as SO_RCVBUF limits to the buffer size
net.core.rmem_max, which is usually much smaller than 128MB udevd requests,
uevents buffer size was not sufficient.

This fixes the ordering of the request: SO_RCVBUFFORCE first, and
fallback to SO_RCVBUF. Then, udevd's uevent buffer size can be set to
128MB.

This also revert 903893237a.

Fixes #11314 and #10754.
This commit is contained in:
Yu Watanabe 2019-01-12 05:24:54 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 28daa1d10d
commit ee0b9e721a

View file

@ -93,14 +93,8 @@ _public_ int sd_device_monitor_set_receive_buffer_size(sd_device_monitor *m, siz
assert_return(m, -EINVAL);
assert_return((size_t) n == size, -EINVAL);
if (m->bound)
return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"sd-device-monitor: Socket fd is already bound. "
"It may be dangerous to change buffer size. "
"Refusing to change buffer size.");
if (setsockopt_int(m->sock, SOL_SOCKET, SO_RCVBUF, n) < 0) {
r = setsockopt_int(m->sock, SOL_SOCKET, SO_RCVBUFFORCE, n);
if (setsockopt_int(m->sock, SOL_SOCKET, SO_RCVBUFFORCE, n) < 0) {
r = setsockopt_int(m->sock, SOL_SOCKET, SO_RCVBUF, n);
if (r < 0)
return r;
}