Mercurial > pidgin.yaz
comparison libfaim/conn.c @ 2034:6bdf9954097c
[gaim-migrate @ 2044]
oscar is much less segfaulty. and more reliable. yes.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 05:28:08 +0000 |
parents | 109cacf1ff97 |
children |
comparison
equal
deleted
inserted
replaced
2033:705783e5ab8c | 2034:6bdf9954097c |
---|---|
20 * @sess: Session to be cleared | 20 * @sess: Session to be cleared |
21 * | 21 * |
22 * Clears out the connection list and kills any connections left. | 22 * Clears out the connection list and kills any connections left. |
23 * | 23 * |
24 */ | 24 */ |
25 faim_internal void aim_connrst(struct aim_session_t *sess) | 25 static void aim_connrst(struct aim_session_t *sess) |
26 { | 26 { |
27 faim_mutex_init(&sess->connlistlock); | 27 faim_mutex_init(&sess->connlistlock); |
28 if (sess->connlist) { | 28 if (sess->connlist) { |
29 struct aim_conn_t *cur = sess->connlist, *tmp; | 29 struct aim_conn_t *cur = sess->connlist, *tmp; |
30 | 30 |
70 * @sess: Session | 70 * @sess: Session |
71 * | 71 * |
72 * Allocate a new empty connection structure. | 72 * Allocate a new empty connection structure. |
73 * | 73 * |
74 */ | 74 */ |
75 faim_internal struct aim_conn_t *aim_conn_getnext(struct aim_session_t *sess) | 75 static struct aim_conn_t *aim_conn_getnext(struct aim_session_t *sess) |
76 { | 76 { |
77 struct aim_conn_t *newconn, *cur; | 77 struct aim_conn_t *newconn, *cur; |
78 | 78 |
79 if (!(newconn = malloc(sizeof(struct aim_conn_t)))) | 79 if (!(newconn = malloc(sizeof(struct aim_conn_t)))) |
80 return NULL; | 80 return NULL; |
189 for (cur = sess->connlist; cur; cur = cur->next) { | 189 for (cur = sess->connlist; cur; cur = cur->next) { |
190 if ((cur->type == type) && !(cur->status & AIM_CONN_STATUS_INPROGRESS)) | 190 if ((cur->type == type) && !(cur->status & AIM_CONN_STATUS_INPROGRESS)) |
191 break; | 191 break; |
192 } | 192 } |
193 faim_mutex_unlock(&sess->connlistlock); | 193 faim_mutex_unlock(&sess->connlistlock); |
194 | |
195 return cur; | |
196 } | |
197 | |
198 faim_export struct aim_conn_t *aim_getconn_type_all(struct aim_session_t *sess, | |
199 int type) | |
200 { | |
201 struct aim_conn_t *cur; | |
202 | |
203 faim_mutex_lock(&sess->connlistlock); | |
204 for (cur = sess->connlist; cur; cur = cur->next) { | |
205 if (cur->type == type) | |
206 break; | |
207 } | |
208 faim_mutex_unlock(&sess->connlistlock); | |
209 | |
210 return cur; | |
211 } | |
212 | |
213 /* If you pass -1 for the fd, you'll get what you ask for. Gibberish. */ | |
214 faim_export struct aim_conn_t *aim_getconn_fd(struct aim_session_t *sess, | |
215 int fd) | |
216 { | |
217 struct aim_conn_t *cur; | |
218 | |
219 faim_mutex_lock(&sess->connlistlock); | |
220 for (cur = sess->connlist; cur; cur = cur->next) { | |
221 if (cur->fd == fd) | |
222 break; | |
223 } | |
224 faim_mutex_unlock(&sess->connlistlock); | |
225 | |
194 return cur; | 226 return cur; |
195 } | 227 } |
196 | 228 |
197 /** | 229 /** |
198 * aim_proxyconnect - An extrememly quick and dirty SOCKS5 interface. | 230 * aim_proxyconnect - An extrememly quick and dirty SOCKS5 interface. |
391 conn->subtype = src->subtype; | 423 conn->subtype = src->subtype; |
392 conn->seqnum = src->seqnum; | 424 conn->seqnum = src->seqnum; |
393 conn->priv = src->priv; | 425 conn->priv = src->priv; |
394 conn->lastactivity = src->lastactivity; | 426 conn->lastactivity = src->lastactivity; |
395 conn->forcedlatency = src->forcedlatency; | 427 conn->forcedlatency = src->forcedlatency; |
428 conn->sessv = src->sessv; | |
396 | 429 |
397 /* clone handler list */ | 430 /* clone handler list */ |
398 for (cur = src->handlerlist; cur; cur = cur->next) { | 431 for (cur = src->handlerlist; cur; cur = cur->next) { |
399 aim_conn_addhandler(sess, conn, cur->family, cur->type, | 432 aim_conn_addhandler(sess, conn, cur->family, cur->type, |
400 cur->handler, cur->flags); | 433 cur->handler, cur->flags); |
430 | 463 |
431 if ((connstruct=aim_conn_getnext(sess))==NULL) | 464 if ((connstruct=aim_conn_getnext(sess))==NULL) |
432 return NULL; | 465 return NULL; |
433 | 466 |
434 faim_mutex_lock(&connstruct->active); | 467 faim_mutex_lock(&connstruct->active); |
435 | 468 |
469 connstruct->sessv = (void *)sess; | |
436 connstruct->type = type; | 470 connstruct->type = type; |
437 | 471 |
438 if (!dest) { /* just allocate a struct */ | 472 if (!dest) { /* just allocate a struct */ |
439 connstruct->fd = -1; | 473 connstruct->fd = -1; |
440 connstruct->status = 0; | 474 connstruct->status = 0; |
897 aim_tx_flushqueue(sess); | 931 aim_tx_flushqueue(sess); |
898 | 932 |
899 return 0; | 933 return 0; |
900 } | 934 } |
901 | 935 |
936 faim_export struct aim_session_t *aim_conn_getsess(struct aim_conn_t *conn) | |
937 { | |
938 | |
939 if (!conn) | |
940 return NULL; | |
941 | |
942 return (struct aim_session_t *)conn->sessv; | |
943 } | |
944 | |
902 /* | 945 /* |
903 * aim_logoff() | 946 * aim_logoff() |
904 * | 947 * |
905 * Closes -ALL- open connections. | 948 * Closes -ALL- open connections. |
906 * | 949 * |