# HG changeset patch # User Mark Doliner # Date 1165479798 0 # Node ID 8138277e9369709da9d496166f8c37afea1275f1 # Parent 1cf62d550a7abc9ceffb63ba3455d9b2e4f1a0c9 [gaim-migrate @ 17915] * Add a little cushion to the rate average calculation to hopefully account for any inaccuracies due to network lag and stuff * If one of our connections is disconnected, close the socket and don't try to write to it again. This will hopefully fix a weird race condition that Kevin was running into? committer: Tailor Script diff -r 1cf62d550a7a -r 8138277e9369 libgaim/protocols/oscar/flap_connection.c --- a/libgaim/protocols/oscar/flap_connection.c Thu Dec 07 08:06:48 2006 +0000 +++ b/libgaim/protocols/oscar/flap_connection.c Thu Dec 07 08:23:18 2006 +0000 @@ -129,7 +129,8 @@ new_current = rateclass_get_new_current(conn, rateclass, &now); - if (new_current < rateclass->alert) + if (new_current < rateclass->alert + 100) + /* (Add 100ms padding to account for inaccuracies in the calculation) */ /* Not ready to send this SNAC yet--keep waiting. */ return TRUE; @@ -185,8 +186,9 @@ gettimeofday(&now, NULL); new_current = rateclass_get_new_current(conn, rateclass, &now); - if (new_current < rateclass->alert) + if (new_current < rateclass->alert + 100) { + /* (Add 100ms padding to account for inaccuracies in the calculation) */ enqueue = TRUE; } else @@ -905,6 +907,10 @@ return; /* Error! */ + gaim_input_remove(conn->watcher_outgoing); + conn->watcher_outgoing = 0; + close(conn->fd); + conn->fd = -1; flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); return; @@ -930,7 +936,7 @@ gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, count); /* If we haven't already started writing stuff, then start the cycle */ - if (conn->watcher_outgoing == 0) + if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) { conn->watcher_outgoing = gaim_input_add(conn->fd, GAIM_INPUT_WRITE, send_cb, conn); diff -r 1cf62d550a7a -r 8138277e9369 libgaim/protocols/oscar/peer.c --- a/libgaim/protocols/oscar/peer.c Thu Dec 07 08:06:48 2006 +0000 +++ b/libgaim/protocols/oscar/peer.c Thu Dec 07 08:23:18 2006 +0000 @@ -421,8 +421,14 @@ return; if (conn->ready) + { + gaim_input_remove(conn->watcher_outgoing); + conn->watcher_outgoing = 0; + close(conn->fd); + conn->fd = -1; peer_connection_schedule_destroy(conn, OSCAR_DISCONNECT_LOST_CONNECTION, NULL); + } else { /* @@ -450,7 +456,7 @@ gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, bs->len); /* If we haven't already started writing stuff, then start the cycle */ - if (conn->watcher_outgoing == 0) + if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) { conn->watcher_outgoing = gaim_input_add(conn->fd, GAIM_INPUT_WRITE, send_cb, conn); @@ -708,8 +714,6 @@ gaim_debug_info("oscar", "Peer connection timed out after 5 seconds. " "Trying next method...\n"); - peer_connection_close(conn); - peer_connection_trynext(conn); /* Cancel this timer. It'll be added again, if needed. */