comparison libpurple/protocols/jabber/bosh.c @ 27577:6d26258e9f1d

propagate from branch 'im.pidgin.pidgin' (head ac87c285c7056f86005dc157b9870745de471f74) to branch 'im.pidgin.cpw.darkrain42.roster' (head 976d874853ac9745edb77d3cf107b92ebc037c10)
author Paul Aurich <paul@darkrain42.org>
date Mon, 06 Jul 2009 04:37:41 +0000
parents 708f92703a13
children f541583e31bd
comparison
equal deleted inserted replaced
27576:b9da56683499 27577:6d26258e9f1d
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 /*