comparison libpurple/protocols/jabber/jabber.c @ 23398:47b709962aab

Only check for EAGAIN if read returned less than 0. This fixes a bug where the recv callback function would get called continuously if the server closed our connection and errno happened to be set to EAGAIN.
author Mark Doliner <mark@kingant.net>
date Mon, 30 Jun 2008 22:58:18 +0000
parents 5c70d953a497
children aaaff38e144f 224169be5830 e23b447aa5ca 28a7992d37b2
comparison
equal deleted inserted replaced
23397:0119f73a76da 23398:47b709962aab
428 jabber_parser_process(js, buf, len); 428 jabber_parser_process(js, buf, len);
429 if(js->reinit) 429 if(js->reinit)
430 jabber_stream_init(js); 430 jabber_stream_init(js);
431 } 431 }
432 432
433 if(errno == EAGAIN) 433 if(len < 0 && errno == EAGAIN)
434 return; 434 return;
435 else 435 else {
436 if (len == 0)
437 purple_debug_info("jabber", "Server closed the connection.\n");
438 else
439 purple_debug_info("jabber", "Disconnected: %s\n", g_strerror(errno));
436 purple_connection_error_reason (js->gc, 440 purple_connection_error_reason (js->gc,
437 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 441 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
438 _("Read Error")); 442 _("Read Error"));
443 }
439 } 444 }
440 445
441 static void 446 static void
442 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition) 447 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition)
443 { 448 {
468 buf[len] = '\0'; 473 buf[len] = '\0';
469 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); 474 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf);
470 jabber_parser_process(js, buf, len); 475 jabber_parser_process(js, buf, len);
471 if(js->reinit) 476 if(js->reinit)
472 jabber_stream_init(js); 477 jabber_stream_init(js);
473 } else if(errno == EAGAIN) { 478 } else if(len < 0 && errno == EAGAIN) {
474 return; 479 return;
475 } else { 480 } else {
481 if (len == 0)
482 purple_debug_info("jabber", "Server closed the connection.\n");
483 else
484 purple_debug_info("jabber", "Disconnected: %s\n", g_strerror(errno));
476 purple_connection_error_reason (js->gc, 485 purple_connection_error_reason (js->gc,
477 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 486 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
478 _("Read Error")); 487 _("Read Error"));
479 } 488 }
480 } 489 }