im.pidgin.pidgin: 5cfc19787cb16932e5e50c4034a7c46699fe1c51
jeff2 at soc.pidgin.im
jeff2 at soc.pidgin.im
Sat Jan 26 23:40:37 EST 2008
-----------------------------------------------------------------
Revision: 5cfc19787cb16932e5e50c4034a7c46699fe1c51
Ancestor: cbff5094920653b96fd8752191cf581b9fa79846
Author: jeff2 at soc.pidgin.im
Date: 2008-01-27T04:26:38
Branch: im.pidgin.pidgin
Modified files:
libpurple/protocols/myspace/myspace.c
libpurple/protocols/myspace/session.c
libpurple/protocols/myspace/session.h
ChangeLog:
a
-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c 2cb2a52765d149415f563ae70e9c1976a2f39277
+++ libpurple/protocols/myspace/myspace.c 1906a99550dd2786fbd6ff4d11f63eaac4797c49
@@ -2464,29 +2464,27 @@ msim_input_cb(gpointer gc_uncasted, gint
/* Mark down that we got data, so we don't timeout. */
session->last_comm = time(NULL);
- /* Only can handle so much data at once...
- * Should be large enough to hold the largest protocol message.
- */
- if (session->rxoff >= MSIM_READ_BUF_SIZE) {
- purple_debug_error("msim",
- "msim_input_cb: %d-byte read buffer full! rxoff=%d. "
- "If this happens, try recompiling with a higher "
- "MSIM_READ_BUF_SIZE.",
- MSIM_READ_BUF_SIZE, session->rxoff);
- purple_connection_error_reason (gc,
- PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Read buffer full"));
+ /* If approaching end of buffer, reallocate some more memory. */
+ if (session->rxsize < session->rxoff + MSIM_READ_BUF_SIZE) {
+ purple_debug_info("msim",
+ "msim_input_cb: %d-byte read buffer full, rxoff=%d, " "growing by %d bytes\n",
+ session->rxsize, session->rxoff, MSIM_READ_BUF_SIZE);
+ session->rxsize += MSIM_READ_BUF_SIZE;
+ session->rxbuf = g_realloc(session->rxbuf, session->rxsize);
+
return;
}
- purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n",
- session->rxoff, MSIM_READ_BUF_SIZE,
- MSIM_READ_BUF_SIZE - session->rxoff);
+ purple_debug_info("msim", "dynamic buffer at %d (max %d), reading up to %d\n",
+ session->rxoff, session->rxsize,
+ MSIM_READ_BUF_SIZE - session->rxoff - 1);
/* Read into buffer. On Win32, need recv() not read(). session->fd also holds
* the file descriptor, but it sometimes differs from the 'source' parameter.
*/
- n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0);
+ n = recv(session->fd,
+ session->rxbuf + session->rxoff,
+ session->rxsize - session->rxoff - 1, 0);
if (n < 0 && errno == EAGAIN) {
return;
@@ -2506,13 +2504,13 @@ msim_input_cb(gpointer gc_uncasted, gint
return;
}
- if (n + session->rxoff >= MSIM_READ_BUF_SIZE) {
+ if (n + session->rxoff > session->rxsize) {
purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n",
- n, n + session->rxoff, MSIM_READ_BUF_SIZE);
- /* TODO: g_realloc like msn, yahoo, irc, jabber? */
+ n, n + session->rxoff, session->rxsize);
purple_connection_error_reason (gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
- _("Read buffer full"));
+ _("Read buffer full (2)"));
+ return;
}
/* Null terminate */
@@ -2555,6 +2553,7 @@ msim_input_cb(gpointer gc_uncasted, gint
purple_connection_error_reason (gc,
PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
_("Unparseable message"));
+ break;
} else {
/* Process message and then free it (processing function should
* clone message if it wants to keep it afterwards.) */
@@ -2567,7 +2566,7 @@ msim_input_cb(gpointer gc_uncasted, gint
/* Move remaining part of buffer to beginning. */
session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING);
memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING),
- MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf));
+ session->rxsize - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf));
/* Clear end of buffer
* memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf));
============================================================
--- libpurple/protocols/myspace/session.c f120bf5c109b9f70507918c7f4f92285c4528a71
+++ libpurple/protocols/myspace/session.c b04c86f6f2cce01380766179288ea45db239ff24
@@ -59,7 +59,8 @@ msim_session_new(PurpleAccount *acct)
session->server_info = NULL;
session->rxoff = 0;
- session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE);
+ session->rxsize = MSIM_READ_BUF_SIZE;
+ session->rxbuf = g_new0(gchar, session->rxsize);
session->next_rid = 1;
session->last_comm = time(NULL);
session->inbox_status = 0;
============================================================
--- libpurple/protocols/myspace/session.h b03eaaf8edc2bed3f95c57cf46776e4910ab14b3
+++ libpurple/protocols/myspace/session.h 918e825feb8a96057946eb90210c2ae9c7ece6ed
@@ -42,6 +42,7 @@ typedef struct _MsimSession
gchar *rxbuf; /**< Receive buffer */
guint rxoff; /**< Receive buffer offset */
+ guint rxsize; /**< Receive buffer size */
guint next_rid; /**< Next request/response ID */
time_t last_comm; /**< Time received last communication */
guint inbox_status; /**< Bit field of inbox notifications */
More information about the Commits
mailing list