* Modified the XMPP service to use client_read_random_blob(). However, I noticed...
authorArt Cancro <ajc@citadel.org>
Fri, 7 May 2010 21:53:11 +0000 (21:53 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 7 May 2010 21:53:11 +0000 (21:53 +0000)
citadel/modules/xmpp/serv_xmpp.c

index 067faa0a1997ba915c5b5c6440d3f40c127cfb39..c553f24194a26ba22aba1cf5b1fcf82304fb42c1 100644 (file)
@@ -476,23 +476,21 @@ void xmpp_greeting(void) {
 
 /* 
  * Main command loop for XMPP sessions.
- * Right now we're reading one byte at a time and sending it to the XML parser.
- * There's got to be a better way to do this.
  */
 void xmpp_command_loop(void) {
-       char cmdbuf[2];
-       int retval;
+       int rc;
+       StrBuf *stream_input = NewStrBuf();
 
        time(&CC->lastcmd);
-       memset(cmdbuf, 0, sizeof cmdbuf);
-       retval = client_read(cmdbuf, 1);
-       if (retval != 1) {
+       rc = client_read_random_blob(stream_input, 30);
+       if (rc > 0) {
+               XML_Parse(XMPP->xp, ChrPtr(stream_input), rc, 0);
+       }
+       else {
                CtdlLogPrintf(CTDL_ERR, "Client disconnected: ending session.\n");
                CC->kill_me = 1;
-               return;
        }
-
-       XML_Parse(XMPP->xp, cmdbuf, 1, 0);
+       FreeStrBuf(&stream_input);
 }