Mercurial > pidgin
comparison libpurple/protocols/jabber/bosh.c @ 27174:708f92703a13
Don't try to write when the BOSH connection isn't ready.
This was causing a Connection Refused to turn into a Write Error connection
error because jabber_close() calls jabber_bosh_connection_close().
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 25 Jun 2009 02:53:26 +0000 |
parents | a8537bbcfb79 |
children | f541583e31bd |
comparison
equal
deleted
inserted
replaced
27173:a9fdf9327652 | 27174:708f92703a13 |
---|---|
241 int i; | 241 int i; |
242 | 242 |
243 /* Easy solution: Does everyone involved support pipelining? Hooray! Just use | 243 /* Easy solution: Does everyone involved support pipelining? Hooray! Just use |
244 * one TCP connection! */ | 244 * one TCP connection! */ |
245 if (conn->pipelining) | 245 if (conn->pipelining) |
246 return conn->connections[0]; | 246 return conn->connections[0]->ready ? conn->connections[0] : NULL; |
247 | 247 |
248 /* First loop, look for a connection that's ready */ | 248 /* First loop, look for a connection that's ready */ |
249 for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) { | 249 for (i = 0; i < MAX_HTTP_CONNECTIONS; ++i) { |
250 if (conn->connections[i] && conn->connections[i]->ready && | 250 if (conn->connections[i] && conn->connections[i]->ready && |
251 conn->connections[i]->requests == 0) | 251 conn->connections[i]->requests == 0) |
265 /* None available. */ | 265 /* None available. */ |
266 return NULL; | 266 return NULL; |
267 } | 267 } |
268 | 268 |
269 static void | 269 static void |
270 jabber_bosh_connection_send(PurpleBOSHConnection *conn, PurpleBOSHPacketType type, | 270 jabber_bosh_connection_send(PurpleBOSHConnection *conn, |
271 const char *data) | 271 PurpleBOSHPacketType type, const char *data) |
272 { | 272 { |
273 PurpleHTTPConnection *chosen; | 273 PurpleHTTPConnection *chosen; |
274 GString *packet = NULL; | 274 GString *packet = NULL; |
275 | 275 |
276 chosen = find_available_http_connection(conn); | 276 chosen = find_available_http_connection(conn); |
277 | 277 |
278 if (type != PACKET_NORMAL && !chosen) { | 278 if (type != PACKET_NORMAL && !chosen) { |
279 /* | 279 /* |
280 * For non-ordinary traffic, we don't want to 'buffer' it, so use the first | 280 * For non-ordinary traffic, we don't want to 'buffer' it, so use the |
281 * connection. | 281 * first connection. |
282 */ | 282 */ |
283 chosen = conn->connections[0]; | 283 chosen = conn->connections[0]; |
284 | 284 |
285 if (!chosen->ready) | 285 if (!chosen->ready) { |
286 purple_debug_warning("jabber", "First BOSH connection wasn't ready. Bad " | 286 purple_debug_info("jabber", "Unable to find a ready BOSH " |
287 "things may happen.\n"); | 287 "connection. Ignoring send of type 0x%02x.\n", type); |
288 return; | |
289 } | |
288 } | 290 } |
289 | 291 |
290 if (type == PACKET_NORMAL && (!chosen || | 292 if (type == PACKET_NORMAL && (!chosen || |
291 (conn->max_requests > 0 && conn->requests == conn->max_requests))) { | 293 (conn->max_requests > 0 && conn->requests == conn->max_requests))) { |
292 /* | 294 /* |