Mercurial > pidgin
comparison libgaim/protocols/oscar/flap_connection.c @ 15129:8138277e9369
[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 <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 07 Dec 2006 08:23:18 +0000 |
parents | 6cc89a43bf8f |
children | 4934e7a03a98 |
comparison
equal
deleted
inserted
replaced
15128:1cf62d550a7a | 15129:8138277e9369 |
---|---|
127 { | 127 { |
128 guint32 new_current; | 128 guint32 new_current; |
129 | 129 |
130 new_current = rateclass_get_new_current(conn, rateclass, &now); | 130 new_current = rateclass_get_new_current(conn, rateclass, &now); |
131 | 131 |
132 if (new_current < rateclass->alert) | 132 if (new_current < rateclass->alert + 100) |
133 /* (Add 100ms padding to account for inaccuracies in the calculation) */ | |
133 /* Not ready to send this SNAC yet--keep waiting. */ | 134 /* Not ready to send this SNAC yet--keep waiting. */ |
134 return TRUE; | 135 return TRUE; |
135 | 136 |
136 rateclass->current = new_current; | 137 rateclass->current = new_current; |
137 rateclass->last.tv_sec = now.tv_sec; | 138 rateclass->last.tv_sec = now.tv_sec; |
183 guint32 new_current; | 184 guint32 new_current; |
184 | 185 |
185 gettimeofday(&now, NULL); | 186 gettimeofday(&now, NULL); |
186 new_current = rateclass_get_new_current(conn, rateclass, &now); | 187 new_current = rateclass_get_new_current(conn, rateclass, &now); |
187 | 188 |
188 if (new_current < rateclass->alert) | 189 if (new_current < rateclass->alert + 100) |
189 { | 190 { |
191 /* (Add 100ms padding to account for inaccuracies in the calculation) */ | |
190 enqueue = TRUE; | 192 enqueue = TRUE; |
191 } | 193 } |
192 else | 194 else |
193 { | 195 { |
194 rateclass->current = new_current; | 196 rateclass->current = new_current; |
903 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) | 905 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) |
904 /* No worries */ | 906 /* No worries */ |
905 return; | 907 return; |
906 | 908 |
907 /* Error! */ | 909 /* Error! */ |
910 gaim_input_remove(conn->watcher_outgoing); | |
911 conn->watcher_outgoing = 0; | |
912 close(conn->fd); | |
913 conn->fd = -1; | |
908 flap_connection_schedule_destroy(conn, | 914 flap_connection_schedule_destroy(conn, |
909 OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); | 915 OSCAR_DISCONNECT_LOST_CONNECTION, strerror(errno)); |
910 return; | 916 return; |
911 } | 917 } |
912 | 918 |
928 | 934 |
929 /* Add everything to our outgoing buffer */ | 935 /* Add everything to our outgoing buffer */ |
930 gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, count); | 936 gaim_circ_buffer_append(conn->buffer_outgoing, bs->data, count); |
931 | 937 |
932 /* If we haven't already started writing stuff, then start the cycle */ | 938 /* If we haven't already started writing stuff, then start the cycle */ |
933 if (conn->watcher_outgoing == 0) | 939 if ((conn->watcher_outgoing == 0) && (conn->fd != -1)) |
934 { | 940 { |
935 conn->watcher_outgoing = gaim_input_add(conn->fd, | 941 conn->watcher_outgoing = gaim_input_add(conn->fd, |
936 GAIM_INPUT_WRITE, send_cb, conn); | 942 GAIM_INPUT_WRITE, send_cb, conn); |
937 send_cb(conn, conn->fd, 0); | 943 send_cb(conn, conn->fd, 0); |
938 } | 944 } |