summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-01-11 11:55:20 +0100
committerGitHub <noreply@github.com>2024-01-11 11:55:20 +0100
commitdce19b7cce0bef3ec13166bcd85766cc8c0ecdba (patch)
treec7323561a2e877d45c2f361899c050b6c079a1a9
parente8d4e4fe967d6b4f77e5820dafbe84676eb20b25 (diff)
parent534417132e1876cc1a2e38d2a35f5937883be282 (diff)
Merge pull request #185 from jow-/rtnl-enobufs-handling
rtnl: improve event reception in order to avoid ENOBUFS
-rw-r--r--lib/rtnl.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/rtnl.c b/lib/rtnl.c
index b6add37..6d2c819 100644
--- a/lib/rtnl.c
+++ b/lib/rtnl.c
@@ -3618,13 +3618,26 @@ cb_listener_event(struct nl_msg *msg, void *arg)
ucv_put(uc_vm_stack_pop(vm));
}
+ errno = 0;
+
return NL_SKIP;
}
static void
uc_nl_listener_cb(struct uloop_fd *fd, unsigned int events)
{
- nl_recvmsgs_default(nl_conn.evsock);
+ while (true) {
+ errno = 0;
+
+ nl_recvmsgs_default(nl_conn.evsock);
+
+ if (errno != 0) {
+ if (errno != EAGAIN && errno != EWOULDBLOCK)
+ set_error(errno, NULL);
+
+ break;
+ }
+ }
}
static void
@@ -3658,7 +3671,7 @@ uc_nl_evsock_init(void)
fd->cb = uc_nl_listener_cb;
uloop_fd_add(fd, ULOOP_READ);
- nl_socket_set_buffer_size(sock, 65535, 0);
+ nl_socket_set_buffer_size(sock, 1024 * 1024, 0);
nl_socket_disable_seq_check(sock);
nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, cb_listener_event, NULL);
@@ -3707,9 +3720,9 @@ uc_nl_listener(uc_vm_t *vm, size_t nargs)
break;
}
- ucv_array_set(listener_registry, i + 1, ucv_get(cb_func));
l = xalloc(sizeof(*l));
l->index = i;
+
if (!uc_nl_fill_cmds(l->cmds, cmds)) {
uc_vm_raise_exception(vm, EXCEPTION_TYPE, "Invalid command ID");
free(l);
@@ -3717,7 +3730,10 @@ uc_nl_listener(uc_vm_t *vm, size_t nargs)
}
rv = uc_resource_new(listener_type, l);
+
ucv_array_set(listener_registry, i, ucv_get(rv));
+ ucv_array_set(listener_registry, i + 1, ucv_get(cb_func));
+
listener_vm = vm;
return rv;