comparison libfaim/aim_conn.c @ 638:525c566741da

[gaim-migrate @ 648] small libfaim changes. no, it doesn't compile on solaris yet. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 08 Aug 2000 05:02:59 +0000
parents e4c34ca88d9b
children 668b4d544afe
comparison
equal deleted inserted replaced
637:8f0ba638d819 638:525c566741da
51 cur->next = newconn; 51 cur->next = newconn;
52 } 52 }
53 faim_mutex_unlock(&sess->connlistlock); 53 faim_mutex_unlock(&sess->connlistlock);
54 54
55 return newconn; 55 return newconn;
56 }
57
58 static void aim_conn_init(struct aim_conn_t *deadconn)
59 {
60 if (!deadconn)
61 return;
62
63 deadconn->fd = -1;
64 deadconn->subtype = -1;
65 deadconn->type = -1;
66 deadconn->seqnum = 0;
67 deadconn->lastactivity = 0;
68 deadconn->forcedlatency = 0;
69 deadconn->handlerlist = NULL;
70 deadconn->priv = NULL;
71 faim_mutex_init(&deadconn->active, NULL);
72 faim_mutex_init(&deadconn->seqnum_lock, NULL);
73
74 return;
56 } 75 }
57 76
58 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn) 77 void aim_conn_kill(struct aim_session_t *sess, struct aim_conn_t **deadconn)
59 { 78 {
60 struct aim_conn_t *cur; 79 struct aim_conn_t *cur;
81 faim_mutex_unlock(&sess->connlistlock); 100 faim_mutex_unlock(&sess->connlistlock);
82 101
83 /* XXX: do we need this for txqueue too? */ 102 /* XXX: do we need this for txqueue too? */
84 aim_rxqueue_cleanbyconn(sess, *deadconn); 103 aim_rxqueue_cleanbyconn(sess, *deadconn);
85 104
86 aim_conn_close(*deadconn); 105 aim_conn_init(*deadconn);
87 free(*deadconn); 106 free(*deadconn);
88 deadconn = NULL; 107 deadconn = NULL;
89 108
90 return; 109 return;
91 } 110 }
92 111
93 void aim_conn_close(struct aim_conn_t *deadconn) 112 void aim_conn_close(struct aim_conn_t *deadconn)
94 { 113 {
114 int typesav = -1, subtypesav = -1;
115 void *privsav = NULL;
116
117 faim_mutex_destroy(&deadconn->active);
118 faim_mutex_destroy(&deadconn->seqnum_lock);
95 if (deadconn->fd >= 3) 119 if (deadconn->fd >= 3)
96 close(deadconn->fd); 120 close(deadconn->fd);
97 deadconn->fd = -1;
98 deadconn->type = -1;
99 deadconn->seqnum = 0;
100 deadconn->lastactivity = 0;
101 deadconn->forcedlatency = 0;
102 if (deadconn->handlerlist) 121 if (deadconn->handlerlist)
103 aim_clearhandlers(deadconn); 122 aim_clearhandlers(deadconn);
104 deadconn->handlerlist = NULL; 123
105 if (deadconn->priv) 124 typesav = deadconn->type;
125 subtypesav = deadconn->subtype;
126
127 if (deadconn->priv && (deadconn->type != AIM_CONN_TYPE_RENDEZVOUS)) {
106 free(deadconn->priv); 128 free(deadconn->priv);
107 deadconn->priv = NULL; 129 deadconn->priv = NULL;
108 faim_mutex_init(&deadconn->active, NULL); 130 }
109 faim_mutex_init(&deadconn->seqnum_lock, NULL); 131 privsav = deadconn->priv;
132
133 aim_conn_init(deadconn);
134
135 deadconn->type = typesav;
136 deadconn->subtype = subtypesav;
137 deadconn->priv = privsav;
138
139 return;
110 } 140 }
111 141
112 struct aim_conn_t *aim_getconn_type(struct aim_session_t *sess, 142 struct aim_conn_t *aim_getconn_type(struct aim_session_t *sess,
113 int type) 143 int type)
114 { 144 {