|
|
@ -293,12 +293,13 @@ void *receiver(void *arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
conn_instance_t *ci = (conn_instance_t *)arg; |
|
|
|
conn_instance_t *ci = (conn_instance_t *)arg; |
|
|
|
client_instance_t *client, *tmp; |
|
|
|
client_instance_t *client, *tmp; |
|
|
|
struct pollfd fds[65536]; |
|
|
|
int ret, nfds, i, maxfds = 1; |
|
|
|
int ret, nfds, i; |
|
|
|
struct pollfd *fds; |
|
|
|
bool update; |
|
|
|
bool update; |
|
|
|
|
|
|
|
|
|
|
|
rename_proc("creceiver"); |
|
|
|
rename_proc("creceiver"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fds = ckalloc(sizeof(struct pollfd)); |
|
|
|
/* First fd is reserved for the accepting socket */ |
|
|
|
/* First fd is reserved for the accepting socket */ |
|
|
|
fds[0].fd = ci->serverfd; |
|
|
|
fds[0].fd = ci->serverfd; |
|
|
|
fds[0].events = POLLIN; |
|
|
|
fds[0].events = POLLIN; |
|
|
@ -314,6 +315,14 @@ rebuild_fds: |
|
|
|
client->id); |
|
|
|
client->id); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (nfds >= maxfds) { |
|
|
|
|
|
|
|
maxfds = nfds + 1; |
|
|
|
|
|
|
|
fds = realloc(fds, sizeof(struct pollfd) * maxfds); |
|
|
|
|
|
|
|
if (unlikely(!fds)) { |
|
|
|
|
|
|
|
LOGEMERG("FATAL: Failed to realloc fds in receiver!"); |
|
|
|
|
|
|
|
goto out; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
fds[nfds].fd = client->fd; |
|
|
|
fds[nfds].fd = client->fd; |
|
|
|
fds[nfds].events = POLLIN; |
|
|
|
fds[nfds].events = POLLIN; |
|
|
|
fds[nfds].revents = 0; |
|
|
|
fds[nfds].revents = 0; |
|
|
@ -372,6 +381,7 @@ repoll: |
|
|
|
goto rebuild_fds; |
|
|
|
goto rebuild_fds; |
|
|
|
goto repoll; |
|
|
|
goto repoll; |
|
|
|
out: |
|
|
|
out: |
|
|
|
|
|
|
|
free(fds); |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|