send quit message on gui quit + serer recognizes "fucked up" connection now
authorhackbard <hackbard>
Mon, 8 Nov 2004 08:35:23 +0000 (08:35 +0000)
committerhackbard <hackbard>
Mon, 8 Nov 2004 08:35:23 +0000 (08:35 +0000)
nlsop_gui.c
nlsop_server.c

index 8464faf..f2e8c91 100644 (file)
@@ -249,6 +249,17 @@ int nothing(t_event *event,void *allineed) {
   return 1;
 }
 
+int send_quit(t_net *net) {
+
+  unsigned char data;
+
+  data=GUI_QUIT;
+
+  network_send_chan(net,0,&data,1);
+
+  return 1;
+}
+
 int get_command(t_event *event,void *allineed) {
 
   t_net *net;
@@ -275,6 +286,7 @@ int get_command(t_event *event,void *allineed) {
       case GUI_QUIT:
         /* stop everything */
         event_math(0,event,READ,REMOVE);
+        send_quit(net);
         network_shutdown(net);
         input_shutdown(input);
         display_shutdown(display);
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;