Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/soap2.c @ 23328:f06adc198c1d
Patch from tomgr and Maiku that workarounds some OS X issue,
References #5212
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 08 Jun 2008 22:52:01 +0000 |
parents | 84807b5e60fa |
children | f85450504940 |
comparison
equal
deleted
inserted
replaced
23325:8c315f969600 | 23328:f06adc198c1d |
---|---|
80 MsnSoapMessage *message, const char *host, const char *path, | 80 MsnSoapMessage *message, const char *host, const char *path, |
81 MsnSoapCallback cb, gpointer cb_data, gboolean first); | 81 MsnSoapCallback cb, gpointer cb_data, gboolean first); |
82 | 82 |
83 static void msn_soap_request_destroy(MsnSoapRequest *req); | 83 static void msn_soap_request_destroy(MsnSoapRequest *req); |
84 static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect); | 84 static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect); |
85 static void msn_soap_process(MsnSoapConnection *conn); | |
85 | 86 |
86 static gboolean | 87 static gboolean |
87 msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data) | 88 msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data) |
88 { | 89 { |
89 MsnSoapConnection *conn = value; | 90 MsnSoapConnection *conn = value; |
262 | 263 |
263 static void | 264 static void |
264 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) | 265 msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) |
265 { | 266 { |
266 MsnSoapConnection *conn = data; | 267 MsnSoapConnection *conn = data; |
267 int count = 0, cnt; | 268 int count = 0, cnt, perrno; |
268 char buf[8192]; | 269 /* This buffer needs to be larger than any packets received from |
269 char *linebreak; | 270 login.live.com or Adium will fail to receive the packet |
270 char *cursor; | 271 (something weird with the login.live.com server). With NSS it works |
271 gboolean handled = FALSE; | 272 fine, so I believe it's some bug with OS X */ |
273 char buf[16 * 1024]; | |
272 | 274 |
273 if (conn->message == NULL) { | 275 if (conn->message == NULL) { |
274 conn->message = msn_soap_message_new(NULL, NULL); | 276 conn->message = msn_soap_message_new(NULL, NULL); |
275 } | 277 } |
276 | 278 |
279 if (conn->buf == NULL) { | |
280 conn->buf = g_string_new_len(buf, 0); | |
281 } | |
282 | |
277 while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) { | 283 while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) { |
278 purple_debug_info("soap", "read %d bytes\n", cnt); | 284 purple_debug_info("soap", "read %d bytes\n", cnt); |
279 count += cnt; | 285 count += cnt; |
280 if (conn->buf == NULL) { | 286 g_string_append_len(conn->buf, buf, cnt); |
281 conn->buf = g_string_new_len(buf, cnt); | 287 } |
282 } else { | 288 |
283 g_string_append_len(conn->buf, buf, cnt); | 289 /* && count is necessary for Adium, on OS X the last read always |
284 } | 290 return an error, so we want to proceed anyway. See #5212 for |
285 } | 291 discussion on this and the above buffer size issues */ |
286 | 292 if(cnt < 0 && errno == EAGAIN && count == 0) |
287 if (cnt < 0) { | 293 return; |
288 if (errno != EAGAIN) { | 294 |
289 purple_debug_info("soap", "read: %s\n", g_strerror(errno)); | 295 // msn_soap_process could alter errno |
296 perrno = errno; | |
297 msn_soap_process(conn); | |
298 | |
299 if (cnt < 0 && perrno != EAGAIN) { | |
300 purple_debug_info("soap", "read: %s\n", g_strerror(perrno)); | |
301 // It's possible msn_soap_process closed the ssl connection | |
302 if (conn->ssl) { | |
290 purple_ssl_close(conn->ssl); | 303 purple_ssl_close(conn->ssl); |
291 conn->ssl = NULL; | 304 conn->ssl = NULL; |
292 msn_soap_connection_handle_next(conn); | 305 msn_soap_connection_handle_next(conn); |
293 return; | |
294 } else if (count == 0) { | |
295 return; | |
296 } | 306 } |
297 } | 307 } |
298 | 308 } |
299 if (cnt == 0 && count == 0) { | 309 |
300 purple_debug_info("soap", "msn_soap_read_cb() called, but no data available?\n"); | 310 static void |
301 purple_ssl_close(conn->ssl); | 311 msn_soap_process(MsnSoapConnection *conn) { |
302 conn->ssl = NULL; | 312 gboolean handled = FALSE; |
303 msn_soap_connection_handle_next(conn); | 313 char *cursor; |
304 return; | 314 char *linebreak; |
305 } | |
306 | 315 |
307 purple_debug_info("soap", "current %s\n", conn->buf->str); | 316 purple_debug_info("soap", "current %s\n", conn->buf->str); |
308 | 317 |
309 cursor = conn->buf->str + conn->handled_len; | 318 cursor = conn->buf->str + conn->handled_len; |
310 | 319 |