WIP: pth, cleanup, transistion mostly done
[rxpd] / src / rxpd_connection.c
index bf06dbd3558aacf4d4cde59c73188f39bad89886..770ef8bbe26f4f4be3d54e63a41c27620620bdbe 100644 (file)
@@ -27,7 +27,7 @@ rxpd_connection_new (struct rxpd_socket* socket)
   struct rxpd_connection* self;
   self = rxpd_malloc (sizeof (struct rxpd_connection));
 
-  self->fd = accept (socket->fd, NULL, 0);
+  self->fd = pth_accept (socket->fd, NULL, 0);
   if (self->fd == -1)
     abort ();
 
@@ -51,8 +51,6 @@ rxpd_connection_delete (struct rxpd_connection* self)
 {
   if (self)
     {
-      // TODO kill connecter if not self
-
       close (self->fd);
       free (self->tmp_str);
       LLIST_WHILE_HEAD (&self->tmp_list, n)
@@ -131,7 +129,7 @@ rxpd_connection_parse_cmd (void* ptr)
   struct rxpd_base* base = self->socket->base;
 
   char* line;
-  line = rxpd_buffer_readline (&self->in, 0);
+  line = rxpd_buffer_readline (&self->in);
 
   if (!line)
     {
@@ -160,6 +158,7 @@ rxpd_connection_parse_cmd (void* ptr)
   for (i = cmds; i->cmd; ++i)
     if (strncmp (line, i->cmd, i->sz) == 0)
       break;
+
   if (!i->cmd)
     {
       rxpd_log (base, LOG_ERR, "no command\n");
@@ -193,19 +192,20 @@ rxpd_connection_parse_cmd (void* ptr)
         }
     }
 
+
+  //TODO memleak have to call connection_destroy instead just returning
+
   // dispatch
   switch (i->nr)
     {
-#define RXPD_CMD(cmd, _)                                                        \
-case RXPD_CMD_##cmd:                                                            
-
-
-  //event_set (&self->ev, self->fd, EV_READ, rxpd_connection_cmd_##cmd, self);    
-  //rxpd_connection_cmd_##cmd (fd, 0, ptr);                                       
+#define RXPD_CMD(cmd, _)                        \
+case RXPD_CMD_##cmd:                            \
+   rxpd_connection_cmd_##cmd (self);            \
+   rxpd_connection_delete (self);               \
   break;
+
       RXPD_COMMANDS
 #undef RXPD_CMD
-        ;
     }
   return NULL;
 }