server: use edge-triggered FDM handler for the client connections

This commit is contained in:
Daniel Eklöf 2020-01-10 19:30:03 +01:00
parent 629a625422
commit 9141b8a657
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -152,21 +152,21 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
return true; /* Let FDM trigger again when we have more data */ return true; /* Let FDM trigger again when we have more data */
} }
/* Keep filling our buffer of initialization data */ while (client->buffer.left > 0) {
ssize_t count = recv( /* Keep filling our buffer of initialization data */
fd, &client->buffer.data[client->buffer.idx], client->buffer.left, 0); ssize_t count = recv(
fd, &client->buffer.data[client->buffer.idx], client->buffer.left, 0);
if (count < 0) { if (count < 0) {
LOG_ERRNO("failed to read"); if (errno == EAGAIN || errno == EWOULDBLOCK)
goto shutdown; return true;
}
client->buffer.idx += count; LOG_ERRNO("failed to read");
client->buffer.left -= count; goto shutdown;
}
if (client->buffer.left > 0) { client->buffer.idx += count;
/* Not done yet */ client->buffer.left -= count;
return true;
} }
/* All initialization data received - time to instantiate a terminal! */ /* All initialization data received - time to instantiate a terminal! */
@ -288,7 +288,7 @@ fdm_server(struct fdm *fdm, int fd, int events, void *data)
.fd = client_fd, .fd = client_fd,
}; };
if (!fdm_add(server->fdm, client_fd, EPOLLIN, &fdm_client, client)) { if (!fdm_add(server->fdm, client_fd, EPOLLIN | EPOLLET, &fdm_client, client)) {
close(client_fd); close(client_fd);
free(client); free(client);
return false; return false;