Mercurial > pidgin
comparison src/protocols/oscar/rxqueue.c @ 2270:d82efea341ef
[gaim-migrate @ 2280]
new libfaim. stupid bugs.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 12 Sep 2001 00:39:51 +0000 |
| parents | 933346315b9b |
| children | e841b14b5b89 |
comparison
equal
deleted
inserted
replaced
| 2269:7ff6170d84a0 | 2270:d82efea341ef |
|---|---|
| 316 * 0 char -- Always 0x2a | 316 * 0 char -- Always 0x2a |
| 317 * 1 char -- Channel ID. Usually 2 -- 1 and 4 are used during login. | 317 * 1 char -- Channel ID. Usually 2 -- 1 and 4 are used during login. |
| 318 * 2 short -- Sequence number | 318 * 2 short -- Sequence number |
| 319 * 4 short -- Number of data bytes that follow. | 319 * 4 short -- Number of data bytes that follow. |
| 320 */ | 320 */ |
| 321 faim_mutex_lock(&conn->active); | |
| 322 if (aim_bstream_recv(&flaphdr, conn->fd, 6) < 6) { | 321 if (aim_bstream_recv(&flaphdr, conn->fd, 6) < 6) { |
| 323 aim_conn_close(conn); | 322 aim_conn_close(conn); |
| 324 faim_mutex_unlock(&conn->active); | |
| 325 return -1; | 323 return -1; |
| 326 } | 324 } |
| 327 | 325 |
| 328 aim_bstream_rewind(&flaphdr); | 326 aim_bstream_rewind(&flaphdr); |
| 329 | 327 |
| 332 * or we break. We must handle it just in case. | 330 * or we break. We must handle it just in case. |
| 333 */ | 331 */ |
| 334 if (aimbs_get8(&flaphdr) != 0x2a) { | 332 if (aimbs_get8(&flaphdr) != 0x2a) { |
| 335 faimdprintf(sess, 0, "FLAP framing disrupted"); | 333 faimdprintf(sess, 0, "FLAP framing disrupted"); |
| 336 aim_conn_close(conn); | 334 aim_conn_close(conn); |
| 337 faim_mutex_unlock(&conn->active); | |
| 338 return -1; | 335 return -1; |
| 339 } | 336 } |
| 340 | 337 |
| 341 /* allocate a new struct */ | 338 /* allocate a new struct */ |
| 342 if (!(newrx = (aim_frame_t *)malloc(sizeof(aim_frame_t)))) { | 339 if (!(newrx = (aim_frame_t *)malloc(sizeof(aim_frame_t)))) |
| 343 faim_mutex_unlock(&conn->active); | 340 return -1; |
| 344 return -1; | |
| 345 } | |
| 346 memset(newrx, 0, sizeof(aim_frame_t)); | 341 memset(newrx, 0, sizeof(aim_frame_t)); |
| 347 | 342 |
| 348 /* we're doing FLAP if we're here */ | 343 /* we're doing FLAP if we're here */ |
| 349 newrx->hdrtype = AIM_FRAMETYPE_FLAP; | 344 newrx->hdrtype = AIM_FRAMETYPE_FLAP; |
| 350 | 345 |
| 357 if (payloadlen) { | 352 if (payloadlen) { |
| 358 fu8_t *payload = NULL; | 353 fu8_t *payload = NULL; |
| 359 | 354 |
| 360 if (!(payload = (fu8_t *) malloc(payloadlen))) { | 355 if (!(payload = (fu8_t *) malloc(payloadlen))) { |
| 361 aim_frame_destroy(newrx); | 356 aim_frame_destroy(newrx); |
| 362 faim_mutex_unlock(&conn->active); | |
| 363 return -1; | 357 return -1; |
| 364 } | 358 } |
| 365 | 359 |
| 366 aim_bstream_init(&newrx->data, payload, payloadlen); | 360 aim_bstream_init(&newrx->data, payload, payloadlen); |
| 367 | 361 |
| 368 /* read the payload */ | 362 /* read the payload */ |
| 369 if (aim_bstream_recv(&newrx->data, conn->fd, payloadlen) < payloadlen) { | 363 if (aim_bstream_recv(&newrx->data, conn->fd, payloadlen) < payloadlen) { |
| 370 free(payload); | 364 free(payload); |
| 371 aim_frame_destroy(newrx); | 365 aim_frame_destroy(newrx); |
| 372 aim_conn_close(conn); | 366 aim_conn_close(conn); |
| 373 faim_mutex_unlock(&conn->active); | |
| 374 return -1; | 367 return -1; |
| 375 } | 368 } |
| 376 } else | 369 } else |
| 377 aim_bstream_init(&newrx->data, NULL, 0); | 370 aim_bstream_init(&newrx->data, NULL, 0); |
| 378 | 371 |
| 379 faim_mutex_unlock(&conn->active); | |
| 380 | 372 |
| 381 aim_bstream_rewind(&newrx->data); | 373 aim_bstream_rewind(&newrx->data); |
| 382 | 374 |
| 383 newrx->conn = conn; | 375 newrx->conn = conn; |
| 384 | 376 |
