send quit message on gui quit + serer recognizes "fucked up" connection now
[physik/nlsop.git] / nlsop_server.c
index 8472491..7f24e8c 100644 (file)
@@ -56,6 +56,7 @@ int *gi;
 t_net *gnet;
 t_event *gevent;
 t_list *gc_list;
+t_list *gg_list;
 int alert;
 
 /*
@@ -410,7 +411,14 @@ void destroy_it(int signum) {
   printf("connection to client (ch %d) fucked up!\n",*gi);
   event_math(gnet->connection[*gi].fd,gevent,READ,REMOVE);
   network_close(gnet,*gi);
-  list_del_current(gc_list);
+  if(list_search_data(gc_list,gi,sizeof(int))==L_SUCCESS) {
+    list_del_current(gc_list);
+    printf("removed client from list\n");
+  }
+  if(list_search_data(gg_list,gi,sizeof(int))==L_SUCCESS) {
+    list_del_current(gg_list);
+    printf("removed gui from list\n");
+  }
 
   alert=1;
   alarm(0);
@@ -436,6 +444,7 @@ int main(int argc,char **argv)
   gnet=&net;
   gevent=&event;
   gc_list=&c_list;
+  gg_list=&g_list;
 
   /* tzzz ... */
   allyouneed=(void *)addr;