* Fixed handling of ASYN messages, I think.
authorBrian <brian@uncensored.citadel.org>
Fri, 14 Sep 2001 19:56:08 +0000 (19:56 +0000)
committerBrian <brian@uncensored.citadel.org>
Fri, 14 Sep 2001 19:56:08 +0000 (19:56 +0000)
  - If no callback has been registered for a particular command, the _CxClRecv()
  command will actively skip all of the ASYN message (not sure if this works
  correctly for _all_ messages... will wait and see)
* Fixed delivery of express messages.  Misunderstood protocol.
! Need to detect server capabilities and use old-style SEXP when necessary!  At
  present, libCxClient is incompatible with older servers.  This, I assume, is a
  bad thing.

libCxClient/ChangeLog
libCxClient/src/libtransport.c
libCxClient/src/misc.c
libCxClient/src/testlib.cpp
libCxClient/stamp-h.in

index b579d28c0f36fa8c620e44c95932b0b818e5dc3f..61556728bec7d4ee297290b3fefb8cd120aa87e1 100644 (file)
@@ -1,4 +1,14 @@
 $Log$
+Revision 1.17  2001/09/14 19:56:08  brian
+* Fixed handling of ASYN messages, I think.
+  - If no callback has been registered for a particular command, the _CxClRecv()
+  command will actively skip all of the ASYN message (not sure if this works
+  correctly for _all_ messages... will wait and see)
+* Fixed delivery of express messages.  Misunderstood protocol.
+! Need to detect server capabilities and use old-style SEXP when necessary!  At
+  present, libCxClient is incompatible with older servers.  This, I assume, is a
+  bad thing.
+
 Revision 1.16  2001/09/10 22:40:39  brian
 * MAJOR BUG: Memory leaks and protocol misimplementations in misc.c (related
 to Express Messaging).  UGH!
@@ -71,3 +81,4 @@ Revision 1.3  2001/02/07 22:42:24  brian
 
 Revision 1.2  2001/02/07 22:41:51  brian
 * Updated ChangeLog to conform to Citadel/UX standards (kinda)  :)
+
index 8f2abeb73a66629db7f87f562246061ad59f4bcf..bf57b131271258d58273c2f2e4bbf84b7baa0db2 100644 (file)
@@ -594,7 +594,7 @@ char                *ss;
         **/
        if(!sock) return;
 
-       DPF((DFA,"REALSEND: \"%s\"", s));
+       DPF((DFA,"PROT --> \"%s\"", s));
 
        ss = (char *)CxMalloc(strlen(s)+2);
        sprintf(ss,"%s\n",s);
@@ -679,14 +679,15 @@ static
 int            _CxClRecv( int sock, int *semaphore, char *s, int cxid ) {
 char           substr[4];
 int            i, tmp;
+char           *tmpstr;
 
        /**
         ** If the socket is not open, there's no point in going here.
         **/
-       DPF((DFA,"Receive on %d", sock));
+       DPF((DFA,"RECV on %d", sock));
        if(!sock) {
                DPF((DFA,"No socket."));
-               return(0);
+               return( 0 );
        }
 
        /**
@@ -720,7 +721,7 @@ RETRY_RECV:
         **/
        s[i] = 0;
 
-       DPF((DFA,"I got \"%s\"",s));
+       DPF((DFA,"PROT <-- \"%s\"", s));
 
        strncpy(substr,s,4);
 
@@ -741,11 +742,8 @@ RETRY_RECV:
                 ** This removes the result code & other data from the
                 ** returned string.  This is _really_ going to mess with
                 ** lots of code.  Ugh.
-                **/
-               DPF((DFA," s: \"%s\"", s));
-
-               /**
-                ** Shift the entire string left 4 places.
+                **
+                ** (Shift the entire string left 4 places.)
                 **/
                for(tmp = 0; tmp < strlen(s); tmp++) {
                        if(tmp+4 < strlen(s)) s[tmp] = s[tmp+4];
@@ -790,18 +788,59 @@ RETRY_RECV:
                                        /**
                                         ** ... Callback has failed.  We need to
                                         ** proactively ignore this message now.
+                                        ** NOTE: WE MAY NEED TO ROLL THE SOCKET
+                                        ** FORWARD TO SKIP ALL OUT-OF-BAND
+                                        ** MESSAGES!
                                         **/
 
-                                       /** INCOMPLETE **/
+                                       DPF((DFA,"PROT: ROLL: Rolling socket forward (CALLBACK FAILURE)"));
+                                       tmpstr = (char *)CxMalloc( 255 );
+                                       bzero( tmpstr, 254 );
+                                       i = _CxClRecv( sock, semaphore, tmpstr, cxid );
+                                       do {
+
+                                               i = _CxClRecv( sock, semaphore, tmpstr, cxid );
+                                               DPF(( DFA,"PROT: ROLL: i: %d", i ));
+
+                                       } while( i<0 );
+                                       free( tmpstr );
+                                       DPF((DFA,"PROT: ROLL: Cleared OOB data."));
+
                                        goto RETRY_RECV;
 
+                               /**
+                                ** Previously, I returned 000 upon receiving an
+                                ** ASYN message.  This was the incorrect behaviour,
+                                ** as the expected RECV operation has _not_ been
+                                ** completed!  At this point, our Callback should've
+                                ** executed appropriately, and we can resume reading
+                                ** from the Socket as previously planned.
+                                **/
                                } else {
-                                       return( 000 );
+
+                               
+                                       goto RETRY_RECV;
                                }
 
+                       /**
+                        ** If there are no callback handles, we need to ignore
+                        ** what we just saw.  NOTE: WE MAY NEED TO ROLL THE
+                        ** SOCKET FORWARD TO SKIP ALL OUT-OF-BAND MESSAGES!
+                        **/
                        } else {
 
-                                       /** INCOMPLETE **/
+                                       DPF((DFA,"PROT: ROLL: Rolling socket forward (NO CALLBACK)"));
+                                       tmpstr = (char *)CxMalloc( 255 );
+                                       bzero( tmpstr, 254 );
+                                       i = _CxClRecv( sock, semaphore, tmpstr, cxid );
+                                       do {
+
+                                               i = _CxClRecv( sock, semaphore, tmpstr, cxid );
+                                               DPF(( DFA,"PROT: ROLL: i: %d", i ));
+
+                                       } while( i<0 );
+                                       free( tmpstr );
+                                       DPF((DFA,"PROT: ROLL: Cleared OOB data."));
                                        goto RETRY_RECV;
 
                        }
index 0efd590843fdaff2149a83e82801e848171d5a3e..d89a6f500e3e0196e2806d9a10f99016d38431e7 100644 (file)
@@ -251,7 +251,7 @@ int         rc;
                        if( rc<0 ) {
                                DPF(( DFA, "data_buf szlen %d", strlen(data_buf) + strlen(buf) +1));
                                if( strlen(buf) ) {
-                                       realloc(data_buf, strlen(data_buf)+strlen(buf)+1);
+                                       data_buf = realloc(data_buf, strlen(data_buf)+strlen(buf)+1);
                                        strcat(data_buf, buf);
                                }
                        }
index ce1c111edb36b7783a998cfd255e7e51327d3dee..1e40a56ccb678e2499f209cc24f2bfba057714c5 100644 (file)
@@ -67,7 +67,9 @@ int           hndl;
                        fl = CxLlFlush(fl);
 
                        CxMiExpSend(hndl, "detsaoT","Hello, World.  This is a long diatribe\n on the evils of something\nof which the world may never know.");
+
                        CxMiExpSend(hndl, "detsaoT","How are you?  I am fine.  If you see the optional potential of the explicit implicity of the file, you'll know what I mean.");
+
                        CxMiExpSend(hndl, "detsaoT","Blah blah blah.");
 
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9788f70238c91894045d22366fa941580826c3c1 100644 (file)
@@ -0,0 +1 @@
+timestamp