summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-08-24 17:12:18 +0200
committerAki <please@ignore.pl>2020-08-24 17:12:18 +0200
commit1667f1be988e9a7f3ae745138b8bd5ecfdc165f5 (patch)
treea5d5d90a5b044eef13c3c5516fba2a20bebbfd3c
parente3d50af2ce41846fefda2a45ed153b05a02cf2f0 (diff)
downloadplop-1667f1be988e9a7f3ae745138b8bd5ecfdc165f5.zip
plop-1667f1be988e9a7f3ae745138b8bd5ecfdc165f5.tar.gz
plop-1667f1be988e9a7f3ae745138b8bd5ecfdc165f5.tar.bz2
Extended error handling of accept in server
-rw-r--r--plop.c28
1 files changed, 27 insertions, 1 deletions
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.