From: Brian Date: Fri, 14 Sep 2001 19:56:08 +0000 (+0000) Subject: * Fixed handling of ASYN messages, I think. X-Git-Tag: v7.86~6780 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=7b95baa30395dd014b952d4280c7e12cb353c202;p=citadel.git * 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. --- diff --git a/libCxClient/ChangeLog b/libCxClient/ChangeLog index b579d28c0..61556728b 100644 --- a/libCxClient/ChangeLog +++ b/libCxClient/ChangeLog @@ -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) :) + diff --git a/libCxClient/src/libtransport.c b/libCxClient/src/libtransport.c index 8f2abeb73..bf57b1312 100644 --- a/libCxClient/src/libtransport.c +++ b/libCxClient/src/libtransport.c @@ -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; } diff --git a/libCxClient/src/misc.c b/libCxClient/src/misc.c index 0efd59084..d89a6f500 100644 --- a/libCxClient/src/misc.c +++ b/libCxClient/src/misc.c @@ -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); } } diff --git a/libCxClient/src/testlib.cpp b/libCxClient/src/testlib.cpp index ce1c111ed..1e40a56cc 100644 --- a/libCxClient/src/testlib.cpp +++ b/libCxClient/src/testlib.cpp @@ -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."); diff --git a/libCxClient/stamp-h.in b/libCxClient/stamp-h.in index e69de29bb..9788f7023 100644 --- a/libCxClient/stamp-h.in +++ b/libCxClient/stamp-h.in @@ -0,0 +1 @@ +timestamp