Changeset 7a8c1c4e in mainline
- Timestamp:
- 2011-12-14T17:11:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0edaf0f6
- Parents:
- bbf159a
- Location:
- uspace/srv/net/tl/tcp
- Files:
-
- 6 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 -
uspace/srv/net/tl/tcp/conn.h
rbbf159a r7a8c1c4e 40 40 41 41 extern tcp_conn_t *tcp_conn_new(tcp_sock_t *, tcp_sock_t *); 42 extern void tcp_conn_delete(tcp_conn_t *); 42 43 extern void tcp_conn_add(tcp_conn_t *); 43 44 extern void tcp_conn_remove(tcp_conn_t *); -
uspace/srv/net/tl/tcp/sock.c
rbbf159a r7a8c1c4e 615 615 } while (trc == TCP_EOK); 616 616 617 tcp_uc_delete(socket->conn); 618 617 619 rc = socket_destroy(net_sess, socket_id, &client->sockets, &gsock, 618 620 tcp_free_sock_data); -
uspace/srv/net/tl/tcp/tcp_type.h
rbbf159a r7a8c1c4e 166 166 /** True if connection was reset */ 167 167 bool reset; 168 /** True if connection was deleted by user */ 169 bool deleted; 168 170 /** Protects @c cstate */ 169 171 fibril_mutex_t cstate_lock; -
uspace/srv/net/tl/tcp/ucall.c
rbbf159a r7a8c1c4e 251 251 } 252 252 253 /** Delete connection user call. 254 * 255 * (Not in spec.) Inform TCP that the user is done with this connection 256 * and will not make any further calls/references to it. TCP can deallocate 257 * the connection from now on. 258 */ 259 void tcp_uc_delete(tcp_conn_t *conn) 260 { 261 log_msg(LVL_DEBUG, "tcp_uc_delete()"); 262 tcp_conn_delete(conn); 263 } 253 264 254 265 /* -
uspace/srv/net/tl/tcp/ucall.h
rbbf159a r7a8c1c4e 48 48 extern void tcp_uc_abort(tcp_conn_t *); 49 49 extern void tcp_uc_status(tcp_conn_t *, tcp_conn_status_t *); 50 extern void tcp_uc_delete(tcp_conn_t *); 50 51 51 52 /*
Note:
See TracChangeset
for help on using the changeset viewer.