]> code.citadel.org Git - citadel.git/commitdiff
* citadel.c: added some experimental code to automatically reconnect
authorArt Cancro <ajc@citadel.org>
Thu, 24 Dec 1998 01:43:35 +0000 (01:43 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 24 Dec 1998 01:43:35 +0000 (01:43 +0000)
          to the server if the connection is broken.  For some reason, it only
          works once.

citadel/ChangeLog
citadel/citadel.c
citadel/commands.c
citadel/ipc_c_tcp.c

index bce8600d541fd8b7e15bc24bee73613ead141dc5..bfc96bfcaf7271bfd1ee63fed27b3c4f43482507 100644 (file)
@@ -1,3 +1,8 @@
+Wed Dec 23 20:42:49 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * citadel.c: added some experimental code to automatically reconnect
+         to the server if the connection is broken.  For some reason, it only
+         works once.
+
 Wed Dec 23 18:47:12 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * sysdep.c: ignore SIGPIPE.  This keeps broken connections from
          crashing the whole server.
index b09f28442d609aec8abc6a6bbd6aea1b41942a6a..8a0874e7c013ab75260233e02165ca77bd37cc0d 100644 (file)
@@ -84,6 +84,15 @@ char floorlist[128][256];            /* names of floors */
 char express_msgs = 0;                 /* express messages waiting! */
 char last_paged[32]="";
 
+jmp_buf jmp_reconnect;                 /* for server reconnects */
+char re_username[32];
+char re_password[32];
+
+void sigpipehandler(int nothing) {
+       printf("Longjumpfing with %d\n", nothing);
+       longjmp(jmp_reconnect, nothing);
+       }
+
 /*
  * here is our 'clean up gracefully and exit' routine
  */
@@ -696,6 +705,7 @@ int set_password(void) {
                serv_puts(buf);
                serv_gets(buf);
                printf("%s\n",&buf[4]);
+               strcpy(re_password, pass1);
                return(0);
                }
        else {
@@ -803,9 +813,9 @@ void enternew(char *desc, char *buf, int maxlen)
 int main(int argc, char **argv)
 {
 int a,b,mcmd;
-int termn8 = 0;
 char aaa[100],bbb[100],ccc[100],eee[100];      /* general purpose variables */
 char argbuf[32];                               /* command line buf */
+int termn8 = 0;
 
 
 sttybbs(SB_SAVE);              /* Store the old terminal parameters */
@@ -844,16 +854,6 @@ printf(" ctrl-s  ctrl-o  ctrl-c\n\n");
 formout("hello");              /* print the opening greeting */
 printf("\n");
 
-       /* if we're not the login shell, try auto-login */
-if (getppid()!=1) {
-       serv_puts("AUTO");
-       serv_gets(aaa);
-       if (aaa[0]=='2') {
-               load_user_info(&aaa[4]);
-               goto PWOK;
-               }
-       }
-
 GSTA:  termn8=0; newnow=0;
        do {
                if (strlen(rc_username) > 0) {
@@ -877,6 +877,7 @@ GSTA:       termn8=0; newnow=0;
                }
 
        /* sign on to the server */
+       strcpy(re_username, fullname);
        snprintf(aaa,sizeof aaa,"USER %s",fullname);
        serv_puts(aaa);
        serv_gets(aaa);
@@ -894,6 +895,7 @@ GSTA:       termn8=0; newnow=0;
        serv_puts(aaa);
        serv_gets(aaa);
        if (aaa[0]=='2') {
+               strcpy(re_password, eee);
                load_user_info(&aaa[4]);
                goto PWOK;
                }
@@ -987,6 +989,24 @@ PWOK:      printf("%s\nAccess level: %d (%s)\nUser #%ld / Call #%d\n",
                else    readmsgs(1,1,0);
 
 do {   /* MAIN LOOP OF PROGRAM */
+
+       /* Reconnect to the server if the connection was broken */
+       if (setjmp(jmp_reconnect)) {
+               attach_to_server(argc,argv);
+               serv_gets(aaa);
+               if (aaa[0]!='2') { printf("%s\n", &aaa[4]); exit(0); }
+               sprintf(aaa, "USER %s", re_username);
+               serv_puts(aaa);
+               serv_gets(aaa);
+               if (aaa[0]!='3') { printf("%s\n", &aaa[4]); exit(0); }
+               sprintf(aaa, "PASS %s", re_password);
+               serv_puts(aaa);
+               serv_gets(aaa);
+               if (aaa[0]!='2') { printf("%s\n", &aaa[4]); exit(0); }
+               load_user_info(&aaa[4]);
+               }
+       signal(SIGPIPE, sigpipehandler);
+
        signal(SIGINT,SIG_IGN);
        signal(SIGQUIT,SIG_IGN);
        mcmd=getcmd(argbuf);
index 937ea2c885257d8064d807cd9d40d83443a14fca..3888d9185c55b31da6c3f68c3f6700243b56c01a 100644 (file)
@@ -131,7 +131,7 @@ void do_keepalive(void) {
                        if (buf[3]=='*') {
                                express_msgs = 1;
                                if (ok_to_interrupt == 1) {
-                                       printf("\r                    \r");
+                                       printf("\r%64s\r", "");
                                        print_express();
                                        printf("%s%c ",room_name,
                                                room_prompt(room_flags));
index 9e5b4805721e80b49da4cc105d601697fb79765d..c359fcac1f0ed13cb19711539f77757eab3c45c5 100644 (file)
@@ -169,8 +169,8 @@ void serv_read(char *buf, int bytes)
        while(len<bytes) {
                rlen = read(serv_sock,&buf[len],bytes-len);
                if (rlen<1) {
-                       printf("\rNetwork error - connection terminated.\n");
-                       printf("%s\n", strerror(errno));
+                       /* printf("\rNetwork error - connection terminated.\n");
+                       printf("%s\n", strerror(errno)); */
                        logoff(3);
                        }
                len = len + rlen;
@@ -189,8 +189,9 @@ void serv_write(char *buf, int nbytes)
                retval = write(serv_sock, &buf[bytes_written],
                        nbytes - bytes_written);
                if (retval < 1) {
+                       /*
                        printf("\rNetwork error - connection terminated.\n");
-                       printf("%s\n", strerror(errno));
+                       printf("%s\n", strerror(errno)); */
                        logoff(3);
                        }
                bytes_written = bytes_written + retval;