* add possibility to specify the inbound buffer size
authorWilfried Göesgens <willi@citadel.org>
Fri, 21 May 2010 20:22:51 +0000 (20:22 +0000)
committerWilfried Göesgens <willi@citadel.org>
Fri, 21 May 2010 20:22:51 +0000 (20:22 +0000)
* XMPP: increase our buffer on start, so client_read_random_blob() can unveil all its power.

citadel/modules/xmpp/serv_xmpp.c
citadel/sysdep.c
citadel/sysdep_decls.h

index 31656c18b7c3b9f7a1ae91733c89f34ca370a3a9..835b30195bd1230760468a277e1a73ab575e64d0 100644 (file)
@@ -513,6 +513,7 @@ void xmpp_cleanup_function(void) {
  * Here's where our XMPP session begins its happy day.
  */
 void xmpp_greeting(void) {
+       client_set_inbound_buf(4);
        strcpy(CC->cs_clientname, "XMPP session");
        CC->session_specific_data = malloc(sizeof(citxmpp));
        memset(XMPP, 0, sizeof(citxmpp));
index ce3523d98fb47f95096acb65146ecef7642a5eb8..d9f34470e52fb0332b409d448025b52569035f5e 100644 (file)
@@ -622,6 +622,16 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout)
 }
 
 
+/*
+ * to make client_read_random_blob() more efficient, increase buffer size.
+ * just use in greeting function, else your buffer may be flushed
+ */
+void client_set_inbound_buf(long N)
+{
+       FlushStrBuf(CC->ReadBuf);
+       ReAdjustEmptyBuf(CC->ReadBuf, N * SIZ, N * SIZ);
+}
+
 int client_read_random_blob(StrBuf *Target, int timeout)
 {
        CitContext *CCC=CC;
@@ -645,11 +655,30 @@ int client_read_random_blob(StrBuf *Target, int timeout)
                        StrBufAppendBufPlain(Target, pch, len, 0);
                        FlushStrBuf(CCC->ReadBuf);
                        CCC->Pos = NULL;
+#ifdef BIGBAD_IODBG
+                       {
+                               int rv = 0;
+                               char fn [SIZ];
+                               FILE *fd;
+                       
+                               snprintf(fn, SIZ, "/tmp/foolog_%s.%d", CCC->ServiceName, CCC->cs_pid);
+                       
+                               fd = fopen(fn, "a+");
+                               fprintf(fd, "Read: BufSize: %d BufContent: [",
+                                       StrLength(Target));
+                               rv = fwrite(ChrPtr(Target), StrLength(Target), 1, fd);
+                               fprintf(fd, "]\n");
+                       
+                       
+                               fclose(fd);
+                       }
+#endif
+       
                        return StrLength(Target);
                }
                return rc;
        }
-       else 
+       else
                return rc;
 }
 
index 4789914fdbaf0f1479439c046717d27b45e0eeeb..df25cbf9454c3157a5b53108d6f9804172f5461e 100644 (file)
@@ -65,6 +65,7 @@ int client_read (char *buf, int bytes);
 int client_getln (char *buf, int maxbytes);
 int CtdlClientGetLine(StrBuf *Target);
 int client_read_blob(StrBuf *Target, int bytes, int timeout);
+void client_set_inbound_buf(long N);
 int client_read_random_blob(StrBuf *Target, int timeout);
 void sysdep_master_cleanup (void);
 void kill_session (int session_to_kill);