move accept to socket_accept itself
[rxpd] / src / rxpd_socket.c
index 507c561..9c7dd0d 100644 (file)
@@ -129,15 +129,14 @@ rxpd_socket_accept (void* ptr)
 
   pth_event_t ev = pth_event (PTH_EVENT_FD|PTH_UNTIL_FD_READABLE, self->fd);
 
-  rxpd_log (NULL, LOG_NOTICE, "pre ACCEPT\n");
-
   // TODO cancel thread to leave the loop?
   while (pth_wait (ev))
     {
-      rxpd_log (NULL, LOG_NOTICE, "ACCEPT\n");
+      int fd = pth_accept (self->fd, NULL, 0);
+      if (fd == -1)
+        rxpd_die ("error accepting connection\n");
 
-      struct rxpd_connection* conn =
-        rxpd_connection_new (self);
+      struct rxpd_connection* conn = rxpd_connection_new (self, fd);
       rxpd_connection_spawn (conn);
     }