Changeset 7a8c1c4e in mainline for uspace/srv/net/tl/tcp/conn.c
- Timestamp:
- 2011-12-14T17:11:31Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0edaf0f6
- Parents:
- bbf159a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/conn.c
rbbf159a r7a8c1c4e 61 61 static void tcp_conn_tw_timer_clear(tcp_conn_t *conn); 62 62 63 /** Create new segmentstructure.63 /** Create new connection structure. 64 64 * 65 65 * @param lsock Local socket (will be deeply copied) 66 66 * @param fsock Foreign socket (will be deeply copied) 67 * @return New segmentor NULL67 * @return New connection or NULL 68 68 */ 69 69 tcp_conn_t *tcp_conn_new(tcp_sock_t *lsock, tcp_sock_t *fsock) … … 120 120 conn->cstate = st_listen; 121 121 conn->reset = false; 122 conn->deleted = false; 122 123 conn->ap = ap_passive; 123 124 conn->fin_is_acked = false; … … 143 144 } 144 145 146 /** Destroy connection structure. 147 * 148 * Connection structure should be destroyed when both of two conditions are 149 * met: (1) user has deleted the connection and (2) the connection has entered 150 * closed state. 151 * 152 * @param conn Connection 153 */ 154 static void tcp_conn_free(tcp_conn_t *conn) 155 { 156 log_msg(LVL_DEBUG, "%s: tcp_conn_free(%p)", conn->name, conn); 157 tcp_tqueue_fini(&conn->retransmit); 158 159 if (conn->rcv_buf != NULL) 160 free(conn->rcv_buf); 161 if (conn->snd_buf != NULL) 162 free(conn->snd_buf); 163 if (conn->tw_timer != NULL) 164 fibril_timer_destroy(conn->tw_timer); 165 free(conn); 166 } 167 168 /** Delete connection. 169 * 170 * The caller promises not make no further references to @a conn. 171 * TCP will free @a conn eventually. 172 * 173 * @param conn Connection 174 */ 175 void tcp_conn_delete(tcp_conn_t *conn) 176 { 177 fibril_mutex_lock(&conn->cstate_lock); 178 conn->deleted = true; 179 180 if (conn->cstate == st_closed) { 181 fibril_mutex_unlock(&conn->cstate_lock); 182 tcp_conn_free(conn); 183 } else { 184 fibril_mutex_unlock(&conn->cstate_lock); 185 } 186 } 187 145 188 /** Enlist connection. 146 189 * … … 166 209 conn->cstate = nstate; 167 210 fibril_condvar_broadcast(&conn->cstate_cv); 168 fibril_mutex_unlock(&conn->cstate_lock); 211 212 if (nstate == st_closed && conn->deleted) { 213 fibril_mutex_unlock(&conn->cstate_lock); 214 tcp_conn_free(conn); 215 } else { 216 fibril_mutex_unlock(&conn->cstate_lock); 217 } 169 218 } 170 219
Note:
See TracChangeset
for help on using the changeset viewer.