Mercurial > pidgin
comparison src/protocols/oscar/txqueue.c @ 9457:14bffb758b34
[gaim-migrate @ 10281]
This fixes a infinite loop on dead socket on sending im images.
It should fix bug #967282
committer: Tailor Script <tailor@pidgin.im>
| author | Tim Ringenbach <marv@pidgin.im> |
|---|---|
| date | Tue, 06 Jul 2004 07:00:32 +0000 |
| parents | f831a38eb6ba |
| children | 9cafe038c95e |
comparison
equal
deleted
inserted
replaced
| 9456:0577bb34622d | 9457:14bffb758b34 |
|---|---|
| 137 * right here. | 137 * right here. |
| 138 * | 138 * |
| 139 */ | 139 */ |
| 140 static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr) | 140 static int aim_tx_enqueue__immediate(aim_session_t *sess, aim_frame_t *fr) |
| 141 { | 141 { |
| 142 int ret; | |
| 142 | 143 |
| 143 if (!fr->conn) { | 144 if (!fr->conn) { |
| 144 faimdprintf(sess, 1, "aim_tx_enqueue: ERROR: packet has no connection\n"); | 145 faimdprintf(sess, 1, "aim_tx_enqueue: ERROR: packet has no connection\n"); |
| 145 aim_frame_destroy(fr); | 146 aim_frame_destroy(fr); |
| 146 return 0; | 147 return 0; |
| 149 if (fr->hdrtype == AIM_FRAMETYPE_FLAP) | 150 if (fr->hdrtype == AIM_FRAMETYPE_FLAP) |
| 150 fr->hdr.flap.seqnum = aim_get_next_txseqnum(fr->conn); | 151 fr->hdr.flap.seqnum = aim_get_next_txseqnum(fr->conn); |
| 151 | 152 |
| 152 fr->handled = 0; /* not sent yet */ | 153 fr->handled = 0; /* not sent yet */ |
| 153 | 154 |
| 154 aim_tx_sendframe(sess, fr); | 155 ret = aim_tx_sendframe(sess, fr); |
| 155 | 156 |
| 156 aim_frame_destroy(fr); | 157 aim_frame_destroy(fr); |
| 157 | 158 |
| 158 return 0; | 159 return ret; |
| 159 } | 160 } |
| 160 | 161 |
| 161 faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)) | 162 faim_export int aim_tx_setenqueue(aim_session_t *sess, int what, int (*func)(aim_session_t *, aim_frame_t *)) |
| 162 { | 163 { |
| 163 | 164 |
| 181 /* | 182 /* |
| 182 * If we want to send on a connection that is in progress, we have to force | 183 * If we want to send on a connection that is in progress, we have to force |
| 183 * them to use the queue based version. Otherwise, use whatever they | 184 * them to use the queue based version. Otherwise, use whatever they |
| 184 * want. | 185 * want. |
| 185 */ | 186 */ |
| 186 if (fr && fr->conn && | 187 if (fr && fr->conn && |
| 187 (fr->conn->status & AIM_CONN_STATUS_INPROGRESS)) { | 188 (fr->conn->status & AIM_CONN_STATUS_INPROGRESS)) { |
| 188 return aim_tx_enqueue__queuebased(sess, fr); | 189 return aim_tx_enqueue__queuebased(sess, fr); |
| 189 } | 190 } |
| 190 | 191 |
| 191 return (*sess->tx_enqueue)(sess, fr); | 192 return (*sess->tx_enqueue)(sess, fr); |
| 223 if (count > aim_bstream_empty(bs)) | 224 if (count > aim_bstream_empty(bs)) |
| 224 count = aim_bstream_empty(bs); /* truncate to remaining space */ | 225 count = aim_bstream_empty(bs); /* truncate to remaining space */ |
| 225 | 226 |
| 226 if (count) { | 227 if (count) { |
| 227 /* | 228 /* |
| 228 * If we're sending a large direct IM (maybe it contains an | 229 * I need to rewrite this. "Updating the UI" doesn't make sense. The program is |
| 229 * image or something), then we want to break it up into chunks | 230 * blocked and the UI can't redraw. We're blocking all of Gaim. We need to set |
| 230 * of 1024 and update the UI between sending each one. This is | 231 * up an actual txqueue and a GAIM_INPUT_WRITE callback and only write when we |
| 231 * kind of ugly. Ideally, if the client wants to send a large | 232 * can. Why is this file called txqueue anyway? Lets rename it to txblock. |
| 232 * amount of data it should just write to the fd directly--we're | |
| 233 * not multithreaded and this is just a stop-gap thingy. | |
| 234 */ | 233 */ |
| 235 if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) && | 234 if ((conn->type == AIM_CONN_TYPE_RENDEZVOUS) && |
| 236 (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { | 235 (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM)) { |
| 237 const char *sn = aim_odc_getsn(conn); | 236 const char *sn = aim_odc_getsn(conn); |
| 238 aim_rxcallback_t userfunc; | 237 aim_rxcallback_t userfunc; |
| 241 int ret; | 240 int ret; |
| 242 | 241 |
| 243 ret = aim_send(conn->fd, bs->data + bs->offset + wrote, 1024); | 242 ret = aim_send(conn->fd, bs->data + bs->offset + wrote, 1024); |
| 244 if (ret > 0) | 243 if (ret > 0) |
| 245 wrote += ret; | 244 wrote += ret; |
| 245 if (ret < 0) | |
| 246 return -1; | |
| 246 if ((userfunc=aim_callhandler(conn->sessv, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER))) | 247 if ((userfunc=aim_callhandler(conn->sessv, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER))) |
| 247 userfunc(conn->sessv, NULL, sn, count-wrote>1024 ? ((double)wrote / count) : 1); | 248 userfunc(conn->sessv, NULL, sn, count-wrote>1024 ? ((double)wrote / count) : 1); |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
