diff src/protocols/msn/httpconn.c @ 13516:4279e5b5e9ac

[gaim-migrate @ 15892] Bring MSN HTTP method closer to working again. Thanks to wabs in #gaim for noticing my braindead mistakes and pointing me in the right direction. This still needs more work. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 15 Mar 2006 04:51:59 +0000
parents 2a9580fc922b
children bbc56ff2bd62
line wrap: on
line diff
--- a/src/protocols/msn/httpconn.c	Wed Mar 15 04:41:44 2006 +0000
+++ b/src/protocols/msn/httpconn.c	Wed Mar 15 04:51:59 2006 +0000
@@ -47,7 +47,7 @@
 	httpconn->servconn = servconn;
 
 	httpconn->tx_buf = gaim_circ_buffer_new(MSN_BUF_LEN);
-	httpconn->tx_handler = -1;
+	httpconn->tx_handler = 0;
 
 	return httpconn;
 }
@@ -121,8 +121,9 @@
 	writelen = gaim_circ_buffer_get_max_read(httpconn->tx_buf);
 
 	if (writelen == 0) {
+		httpconn->waiting_response = TRUE;
 		gaim_input_remove(httpconn->tx_handler);
-		httpconn->tx_handler = -1;
+		httpconn->tx_handler = 0;
 		return;
 	}
 
@@ -137,6 +138,9 @@
 	}
 
 	gaim_circ_buffer_mark_read(httpconn->tx_buf, ret);
+
+	if (ret == writelen)
+		httpconn_write_cb(data, source, cond);
 }
 
 static ssize_t
@@ -149,7 +153,7 @@
 #endif
 
 
-	if (httpconn->tx_handler == -1 && !httpconn->waiting_response)
+	if (httpconn->tx_handler == 0 && !httpconn->waiting_response)
 		res = write(httpconn->fd, data, data_len);
 	else
 	{
@@ -165,7 +169,7 @@
 	} else if (res < 0 || res < data_len) {
 		if (res < 0)
 			res = 0;
-		if (httpconn->tx_handler == -1)
+		if (httpconn->tx_handler == 0 && httpconn->fd)
 			httpconn->tx_handler = gaim_input_add(httpconn->fd,
 				GAIM_INPUT_WRITE, httpconn_write_cb, httpconn);
 		gaim_circ_buffer_append(httpconn->tx_buf, data + res,
@@ -266,7 +270,12 @@
 
 		httpconn->waiting_response = FALSE;
 		if (httpconn->tx_handler > 0)
-			httpconn_write_cb(httpconn, source, GAIM_INPUT_WRITE);
+			gaim_input_remove(httpconn->tx_handler);
+
+		httpconn->tx_handler = gaim_input_add(source,
+			GAIM_INPUT_WRITE, httpconn_write_cb, httpconn);
+
+		httpconn_write_cb(httpconn, source, GAIM_INPUT_WRITE);
 	}
 	else
 	{
@@ -611,6 +620,8 @@
 			if (httpconn->tx_handler > 0)
 				httpconn_write_cb(httpconn, httpconn->fd,
 					GAIM_INPUT_WRITE);
+			else
+				httpconn->dirty = TRUE;
 
 			return TRUE;
 		}
@@ -764,6 +775,8 @@
 
 	if (httpconn->tx_handler > 0)
 		httpconn_write_cb(httpconn, httpconn->fd, GAIM_INPUT_WRITE);
+	else
+		httpconn->dirty = TRUE;
 
 	return TRUE;
 }