summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-22 16:03:17 +0200
committerAki <please@ignore.pl>2021-08-22 16:03:17 +0200
commit31c614d6916c5573eb11a25cce996c5e3afbb5f0 (patch)
tree40f52769f19652957165cd66d299c8eeea507bad
parentfe94acc29d93b766eac79d2f9ded6874919eadfa (diff)
downloadplop-31c614d6916c5573eb11a25cce996c5e3afbb5f0.zip
plop-31c614d6916c5573eb11a25cce996c5e3afbb5f0.tar.gz
plop-31c614d6916c5573eb11a25cce996c5e3afbb5f0.tar.bz2
Fixed poll behaviour
-rw-r--r--main.c4
-rw-r--r--plop.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/main.c b/main.c
index 72ddc49..8ed346c 100644
--- a/main.c
+++ b/main.c
@@ -73,7 +73,7 @@ int main(int argc, char ** argv)
for (int i = 0; i < nfds; ++i)
{
fds[i].fd = -1;
- fds[i].events = POLLIN | POLLOUT;
+ fds[i].events = POLLIN; // TODO: Handle yielded writes
data[i] = NULL;
}
const int server = open_server(NULL, service);
@@ -91,7 +91,7 @@ int main(int argc, char ** argv)
return 5;
for (int i = 0; i < nfds; ++i)
{
- if (-1 == fds[i].fd)
+ if (-1 == fds[i].fd || 0 == fds[i].revents)
continue;
if (NULL == data[i])
{
diff --git a/plop.c b/plop.c
index a1de2d0..d477036 100644
--- a/plop.c
+++ b/plop.c
@@ -241,6 +241,12 @@ int plop_handle_server(const int server)
}
}
+ if (-1 == fcntl(client, F_SETFL, fcntl(client, F_GETFL, 0) | O_NONBLOCK))
+ {
+ close(client);
+ return 0; // TODO: Revisit error handling in server.
+ }
+
struct connection * connection = connection_new(client);
if (NULL == connection)
return -1;