mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
fdm: use poll(3) instead of epoll_wait(2)
poll() is more portable, and since foot doesn’t use _that_ many FDs, there should be no noticeable performance difference between the two.
This commit is contained in:
parent
e19db15104
commit
4fa4d54d2b
9 changed files with 204 additions and 165 deletions
12
server.c
12
server.c
|
|
@ -3,10 +3,10 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include <sys/un.h>
|
||||
|
||||
|
|
@ -120,10 +120,10 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
|||
|
||||
char **argv = NULL;
|
||||
|
||||
if (events & EPOLLHUP)
|
||||
if (events & POLLHUP)
|
||||
goto shutdown;
|
||||
|
||||
xassert(events & EPOLLIN);
|
||||
xassert(events & POLLIN);
|
||||
|
||||
if (client->term != NULL) {
|
||||
uint8_t dummy[128];
|
||||
|
|
@ -299,7 +299,7 @@ shutdown:
|
|||
static bool
|
||||
fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
||||
{
|
||||
if (events & EPOLLHUP)
|
||||
if (events & POLLHUP)
|
||||
return false;
|
||||
|
||||
struct server *server = data;
|
||||
|
|
@ -320,7 +320,7 @@ fdm_server(struct fdm *fdm, int fd, int events, void *data)
|
|||
.fd = client_fd,
|
||||
};
|
||||
|
||||
if (!fdm_add(server->fdm, client_fd, EPOLLIN, &fdm_client, client)) {
|
||||
if (!fdm_add(server->fdm, client_fd, POLLIN, &fdm_client, client)) {
|
||||
close(client_fd);
|
||||
free(client);
|
||||
return false;
|
||||
|
|
@ -422,7 +422,7 @@ server_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.clients = tll_init(),
|
||||
};
|
||||
|
||||
if (!fdm_add(fdm, fd, EPOLLIN, &fdm_server, server))
|
||||
if (!fdm_add(fdm, fd, POLLIN, &fdm_server, server))
|
||||
goto err;
|
||||
|
||||
LOG_INFO("accepting connections on %s", sock_path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue