Mercurial > pidgin
comparison libpurple/protocols/oscar/flap_connection.c @ 23580:e8bea84f63b6
merge of '88c7f87fb5a74f975cf06c472059ecf081c54042'
and 'fe134224188f83f69a5367395922807444d46f49'
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 21 Jul 2008 06:33:06 +0000 |
parents | 8dcd6c1b923c |
children | 3b968076a5dc |
comparison
equal
deleted
inserted
replaced
23577:60030a36506e | 23580:e8bea84f63b6 |
---|---|
107 return MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); | 107 return MIN(((rateclass->current * (rateclass->windowsize - 1)) + timediff) / rateclass->windowsize, rateclass->max); |
108 } | 108 } |
109 | 109 |
110 /* | 110 /* |
111 * Attempt to send the contents of a given queue | 111 * Attempt to send the contents of a given queue |
112 * @result TRUE if the queue was completely emptied or was iniitally empty; FALSE if rate limiting prevented it from being emptied | 112 * |
113 * @return TRUE if the queue was completely emptied or was initially | |
114 * empty; FALSE if rate limiting prevented it from being | |
115 * emptied. | |
113 */ | 116 */ |
114 static gboolean flap_connection_send_snac_queue(FlapConnection *conn, struct timeval now, GQueue *queue) | 117 static gboolean flap_connection_send_snac_queue(FlapConnection *conn, struct timeval now, GQueue *queue) |
115 { | 118 { |
116 while (!g_queue_is_empty(queue)) | 119 while (!g_queue_is_empty(queue)) |
117 { | 120 { |
129 | 132 |
130 /* (Add 100ms padding to account for inaccuracies in the calculation) */ | 133 /* (Add 100ms padding to account for inaccuracies in the calculation) */ |
131 if (new_current < rateclass->alert + 100) | 134 if (new_current < rateclass->alert + 100) |
132 /* Not ready to send this SNAC yet--keep waiting. */ | 135 /* Not ready to send this SNAC yet--keep waiting. */ |
133 return FALSE; | 136 return FALSE; |
134 | 137 |
135 rateclass->current = new_current; | 138 rateclass->current = new_current; |
136 rateclass->last.tv_sec = now.tv_sec; | 139 rateclass->last.tv_sec = now.tv_sec; |
137 rateclass->last.tv_usec = now.tv_usec; | 140 rateclass->last.tv_usec = now.tv_usec; |
138 } | 141 } |
139 | 142 |
163 /* Both queues emptied. */ | 166 /* Both queues emptied. */ |
164 conn->queued_timeout = 0; | 167 conn->queued_timeout = 0; |
165 return FALSE; | 168 return FALSE; |
166 } | 169 } |
167 } | 170 } |
168 | 171 |
169 /* We couldn't send all our SNACs. Keep trying */ | 172 /* We couldn't send all our SNACs. Keep trying */ |
170 return TRUE; | 173 return TRUE; |
171 } | 174 } |
172 | 175 |
173 /** | 176 /** |
176 * sending this SNAC will induce rate limiting then we delay sending | 179 * sending this SNAC will induce rate limiting then we delay sending |
177 * of the SNAC by putting it into an outgoing holding queue. | 180 * of the SNAC by putting it into an outgoing holding queue. |
178 * | 181 * |
179 * @param data The optional bytestream that makes up the data portion | 182 * @param data The optional bytestream that makes up the data portion |
180 * of this SNAC. For empty SNACs this should be NULL. | 183 * of this SNAC. For empty SNACs this should be NULL. |
181 * @param high_priority If TRUE, the SNAC will be queued normally if needed. If FALSE, it wil be queued separately, to be sent only if all high priority SNACs have been sent. | 184 * @param high_priority If TRUE, the SNAC will be queued normally if |
185 * needed. If FALSE, it wil be queued separately, to be sent | |
186 * only if all high priority SNACs have been sent. | |
182 */ | 187 */ |
183 void | 188 void |
184 flap_connection_send_snac_with_priority(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data, gboolean high_priority) | 189 flap_connection_send_snac_with_priority(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data, gboolean high_priority) |
185 { | 190 { |
186 FlapFrame *frame; | 191 FlapFrame *frame; |
237 queued_snac->frame = frame; | 242 queued_snac->frame = frame; |
238 | 243 |
239 if (high_priority) { | 244 if (high_priority) { |
240 if (!conn->queued_snacs) | 245 if (!conn->queued_snacs) |
241 conn->queued_snacs = g_queue_new(); | 246 conn->queued_snacs = g_queue_new(); |
242 g_queue_push_tail(conn->queued_snacs, queued_snac); | 247 g_queue_push_tail(conn->queued_snacs, queued_snac); |
243 } else { | 248 } else { |
244 if (!conn->queued_lowpriority_snacs) | 249 if (!conn->queued_lowpriority_snacs) |
245 conn->queued_lowpriority_snacs = g_queue_new(); | 250 conn->queued_lowpriority_snacs = g_queue_new(); |
246 g_queue_push_tail(conn->queued_lowpriority_snacs, queued_snac); | 251 g_queue_push_tail(conn->queued_lowpriority_snacs, queued_snac); |
247 } | 252 } |
256 } | 261 } |
257 | 262 |
258 void | 263 void |
259 flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data) | 264 flap_connection_send_snac(OscarData *od, FlapConnection *conn, guint16 family, const guint16 subtype, guint16 flags, aim_snacid_t snacid, ByteStream *data) |
260 { | 265 { |
261 flap_connection_send_snac_with_priority(od, conn, family, subtype, flags, snacid, data, /* High priority? */ TRUE); | 266 flap_connection_send_snac_with_priority(od, conn, family, subtype, flags, snacid, data, TRUE); |
262 } | 267 } |
263 | 268 |
264 /** | 269 /** |
265 * This sends an empty channel 4 FLAP. This is sent to signify | 270 * This sends an empty channel 4 FLAP. This is sent to signify |
266 * that we're logging off. This shouldn't really be necessary-- | 271 * that we're logging off. This shouldn't really be necessary-- |
1046 { | 1051 { |
1047 frame->seqnum = ++(conn->seqnum_out); | 1052 frame->seqnum = ++(conn->seqnum_out); |
1048 sendframe_flap(conn, frame); | 1053 sendframe_flap(conn, frame); |
1049 flap_frame_destroy(frame); | 1054 flap_frame_destroy(frame); |
1050 } | 1055 } |
1051 |