From 1667f1be988e9a7f3ae745138b8bd5ecfdc165f5 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 24 Aug 2020 17:12:18 +0200 Subject: Extended error handling of accept in server --- plop.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/plop.c b/plop.c index 8fd8cd1..ec7eb3d 100644 --- a/plop.c +++ b/plop.c @@ -166,7 +166,33 @@ int handle_server(lua_State * L, const int efd, const int server) const int client = accept(server, NULL, NULL); if (-1 == client) { - return -1; // TODO: Consider not crashing entire server because of one accept. + switch (errno) + { + case EAGAIN: +#if EWOULDBLOCK != EAGAIN + case EWOULDBLOCK: +#endif + case ENETDOWN: + case EPROTO: + case ENOPROTOOPT: + case EHOSTDOWN: + case ENONET: + case EHOSTUNREACH: + case EOPNOTSUPP: + case ENETUNREACH: + case ECONNABORTED: + case EMFILE: + case ENFILE: + case ENOBUFS: + case ENOMEM: + { + return 0; + } + default: + { + return -1; + } + } } // TODO: Request is not the enitre state of the client. Make them distinct along with responses. -- cgit v1.1