Mercurial > pidgin.yaz
comparison src/protocols/oscar/rxqueue.c @ 10267:9cafe038c95e
[gaim-migrate @ 11413]
This is some white-space cleanup for oscar, and send an empty channel 4
FLAP when disconnecting. This would have hopefully fixed the problem
Luke was seeing where his AIM account wasn't being signed offline for
a few hours.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 26 Nov 2004 03:52:00 +0000 |
parents | ec3e041dc3bd |
children | 361c9170d8af |
comparison
equal
deleted
inserted
replaced
10266:2a9ec10e0c4c | 10267:9cafe038c95e |
---|---|
3 * (incoming packet) queue. The actual packet handlers are in | 3 * (incoming packet) queue. The actual packet handlers are in |
4 * rxhandlers.c. | 4 * rxhandlers.c. |
5 */ | 5 */ |
6 | 6 |
7 #define FAIM_INTERNAL | 7 #define FAIM_INTERNAL |
8 #include <aim.h> | 8 #include <aim.h> |
9 | 9 |
10 #ifndef _WIN32 | 10 #ifndef _WIN32 |
11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
12 #endif | 12 #endif |
13 | 13 |
14 /* | 14 /* |
15 * | 15 * |
16 */ | 16 */ |
17 faim_internal int aim_recv(int fd, void *buf, size_t count) | 17 faim_internal int aim_recv(int fd, void *buf, size_t count) |
18 { | 18 { |
19 int left, cur; | 19 int left, cur; |
20 | 20 |
21 for (cur = 0, left = count; left; ) { | 21 for (cur = 0, left = count; left; ) { |
22 int ret; | 22 int ret; |
23 | 23 |
24 ret = recv(fd, ((unsigned char *)buf)+cur, left, 0); | 24 ret = recv(fd, ((unsigned char *)buf)+cur, left, 0); |
25 | 25 |
26 /* Of course EOF is an error, only morons disagree with that. */ | 26 /* Of course EOF is an error, only morons disagree with that. */ |
27 if (ret <= 0) | 27 if (ret <= 0) |
28 return -1; | 28 return -1; |
42 { | 42 { |
43 int red = 0; | 43 int red = 0; |
44 | 44 |
45 if (!bs || (fd < 0) || (count < 0)) | 45 if (!bs || (fd < 0) || (count < 0)) |
46 return -1; | 46 return -1; |
47 | 47 |
48 if (count > (bs->len - bs->offset)) | 48 if (count > (bs->len - bs->offset)) |
49 count = bs->len - bs->offset; /* truncate to remaining space */ | 49 count = bs->len - bs->offset; /* truncate to remaining space */ |
50 | 50 |
51 if (count) { | 51 if (count) { |
52 | 52 |
84 */ | 84 */ |
85 static int aim_get_command_flap(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) | 85 static int aim_get_command_flap(aim_session_t *sess, aim_conn_t *conn, aim_frame_t *fr) |
86 { | 86 { |
87 fu8_t hdr_raw[6]; | 87 fu8_t hdr_raw[6]; |
88 aim_bstream_t hdr; | 88 aim_bstream_t hdr; |
89 | 89 |
90 fr->hdrtype = AIM_FRAMETYPE_FLAP; | 90 fr->hdrtype = AIM_FRAMETYPE_FLAP; |
91 | 91 |
92 /* | 92 /* |
93 * Read FLAP header. Six bytes total. | 93 * Read FLAP header. Six bytes total. |
94 * | 94 * |
100 * 0x02 | Sequence number, 2 bytes. | 100 * 0x02 | Sequence number, 2 bytes. |
101 * 0x04 | Number of data bytes that follow, 2 bytes. | 101 * 0x04 | Number of data bytes that follow, 2 bytes. |
102 */ | 102 */ |
103 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); | 103 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); |
104 if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { | 104 if (aim_bstream_recv(&hdr, conn->fd, 6) < 6) { |
105 aim_conn_close(conn); | 105 aim_conn_close(sess, conn); |
106 return -1; | 106 return -1; |
107 } | 107 } |
108 | 108 |
109 aim_bstream_rewind(&hdr); | 109 aim_bstream_rewind(&hdr); |
110 | 110 |
112 * This shouldn't happen unless the socket breaks, the server breaks, | 112 * This shouldn't happen unless the socket breaks, the server breaks, |
113 * or we break. We must handle it just in case. | 113 * or we break. We must handle it just in case. |
114 */ | 114 */ |
115 if (aimbs_get8(&hdr) != 0x2a) { | 115 if (aimbs_get8(&hdr) != 0x2a) { |
116 faimdprintf(sess, 0, "Invalid FLAP frame received on FLAP connection!"); | 116 faimdprintf(sess, 0, "Invalid FLAP frame received on FLAP connection!"); |
117 aim_conn_close(conn); | 117 aim_conn_close(sess, conn); |
118 return -1; | 118 return -1; |
119 } | 119 } |
120 | 120 |
121 fr->hdr.flap.channel = aimbs_get8(&hdr); | 121 fr->hdr.flap.channel = aimbs_get8(&hdr); |
122 fr->hdr.flap.seqnum = aimbs_get16(&hdr); | 122 fr->hdr.flap.seqnum = aimbs_get16(&hdr); |
123 | 123 |
124 return aimbs_get16(&hdr); | 124 return aimbs_get16(&hdr); |
140 /* | 140 /* |
141 * Read rendezvous header | 141 * Read rendezvous header |
142 */ | 142 */ |
143 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); | 143 aim_bstream_init(&hdr, hdr_raw, sizeof(hdr_raw)); |
144 if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { | 144 if (aim_bstream_recv(&hdr, conn->fd, 8) < 8) { |
145 aim_conn_close(conn); | 145 aim_conn_close(sess, conn); |
146 return -1; | 146 return -1; |
147 } | 147 } |
148 | 148 |
149 aim_bstream_rewind(&hdr); | 149 aim_bstream_rewind(&hdr); |
150 | 150 |
210 aim_bstream_init(&fr->data, payload, payloadlen); | 210 aim_bstream_init(&fr->data, payload, payloadlen); |
211 | 211 |
212 /* read the payload */ | 212 /* read the payload */ |
213 if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { | 213 if (aim_bstream_recv(&fr->data, conn->fd, payloadlen) < payloadlen) { |
214 aim_frame_destroy(fr); /* free's payload */ | 214 aim_frame_destroy(fr); /* free's payload */ |
215 aim_conn_close(conn); | 215 aim_conn_close(sess, conn); |
216 return -1; | 216 return -1; |
217 } | 217 } |
218 } else | 218 } else |
219 aim_bstream_init(&fr->data, NULL, 0); | 219 aim_bstream_init(&fr->data, NULL, 0); |
220 | 220 |
232 cur->next = fr; | 232 cur->next = fr; |
233 } | 233 } |
234 | 234 |
235 fr->conn->lastactivity = time(NULL); | 235 fr->conn->lastactivity = time(NULL); |
236 | 236 |
237 return 0; | 237 return 0; |
238 } | 238 } |
239 | 239 |
240 /* | 240 /* |
241 * Purge receive queue of all handled commands (->handled==1). | 241 * Purge receive queue of all handled commands (->handled==1). |
242 * | 242 * |
268 aim_frame_t *currx; | 268 aim_frame_t *currx; |
269 | 269 |
270 for (currx = sess->queue_incoming; currx; currx = currx->next) { | 270 for (currx = sess->queue_incoming; currx; currx = currx->next) { |
271 if ((!currx->handled) && (currx->conn == conn)) | 271 if ((!currx->handled) && (currx->conn == conn)) |
272 currx->handled = 1; | 272 currx->handled = 1; |
273 } | 273 } |
274 | 274 |
275 return; | 275 return; |
276 } | 276 } |