add DXCIDR, fix version no tracking
[spider.git] / src / client.c
index 7b98f66129bb717914495cdbc7b38305667ae300..b38aecf33b6db4924b170a41e35c0465969f8444 100644 (file)
@@ -79,7 +79,7 @@ typedef struct
 } myregex_t;
 
 
-char *node_addr = "localhost"; /* the node tcp address, can be overridden by DXSPIDER_HOST */
+char *node_addr = "127.0.0.1"; /* the node tcp address, can be overridden by DXSPIDER_HOST */
 int node_port = 27754;                 /* the tcp port of the node at the above address can be overidden by DXSPIDER_PORT*/
 char *call;                                            /* the caller's callsign */
 char *connsort;                                        /* the type of connection */
@@ -375,12 +375,12 @@ int fcb_handler(sel_t *sp, int in, int out, int err)
                        default:
                                dbg(DBUF,"got errno %d in input", errno);
                                ending++;
-                               return 0;
+                               return 1;
                        }
                } else if (r == 0) {
                        dbg(DBUF, "ending normally");
                        ending++;
-                       return 0;
+                       return 1;
                }
 
                dbgdump(DBUF, "in ->", buf, r);
@@ -723,7 +723,8 @@ void process_node()
 void term_timeout(int i)
 {
        /* none of this is going to be reused so don't bother cleaning up properly */
-       tcflush(0, TCIOFLUSH);
+       if (isatty(0))
+               tcflush(0, TCIOFLUSH);
        kill(getpid(), 9);                      /* commit suicide */
 }
 
@@ -732,16 +733,22 @@ void terminate(int i)
        signal(SIGALRM, term_timeout);
        alarm(10);
        
-       while ((in && !is_chain_empty(in->outq)) ||
-                  (node && !is_chain_empty(node->outq))) {
+       if (node && node->sp->sort) {
+               sel_close(node->sp);
+       }
+       while (in && in->sp->sort && !is_chain_empty(in->outq)) {
                sel_run();
        }
+       sel_run();
+       sel_run();
+       sel_run();
+       sel_run();
+       sel_run();
+       sel_run();
+       sel_run();
+       sel_run();
        if (in && in->t_set)
                tcsetattr(0, TCSADRAIN, &in->t);
-       if (node) {
-               shutdown(node->cnum, 3);
-               close(node->cnum);
-       }
        exit(i);
 }
 
@@ -749,10 +756,7 @@ void login_timeout(int i)
 {
        write(0, "Timed Out", 10);
        write(0, &nl, 1);
-       sel_run();                                      /* force a coordination */
-       if (in && in->t_set)
-               tcsetattr(0, TCSANOW, &in->t);
-       exit(i);
+       terminate(0);
 }
 
 /*