Changeset 2989c7e in mainline for uspace/srv/net/tcp/conn.c
- Timestamp:
- 2015-05-25T21:04:33Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab6326bc
- Parents:
- 58e9dec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/conn.c
r58e9dec r2989c7e 36 36 37 37 #include <adt/list.h> 38 #include <stdbool.h>39 38 #include <errno.h> 40 39 #include <inet/endpoint.h> 41 40 #include <io/log.h> 42 41 #include <macros.h> 42 #include <nettl/amap.h> 43 #include <stdbool.h> 43 44 #include <stdlib.h> 44 45 #include "conn.h" … … 56 57 #define TIME_WAIT_TIMEOUT (2*MAX_SEGMENT_LIFETIME) 57 58 58 LIST_INITIALIZE(conn_list); 59 FIBRIL_MUTEX_INITIALIZE(conn_list_lock); 59 static LIST_INITIALIZE(conn_list); 60 static FIBRIL_MUTEX_INITIALIZE(conn_list_lock); 61 static amap_t *amap; 60 62 61 63 static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg); 62 64 static void tcp_conn_tw_timer_set(tcp_conn_t *conn); 63 65 static void tcp_conn_tw_timer_clear(tcp_conn_t *conn); 66 67 /** Initialize connections. */ 68 int tcp_conns_init(void) 69 { 70 int rc; 71 72 rc = amap_create(&amap); 73 if (rc != EOK) { 74 assert(rc == ENOMEM); 75 return ENOMEM; 76 } 77 78 return EOK; 79 } 64 80 65 81 /** Create new connection structure. … … 246 262 * Add connection to the connection map. 247 263 */ 248 void tcp_conn_add(tcp_conn_t *conn) 249 { 264 int tcp_conn_add(tcp_conn_t *conn) 265 { 266 inet_ep2_t aepp; 267 int rc; 268 250 269 tcp_conn_addref(conn); 251 270 fibril_mutex_lock(&conn_list_lock); 271 272 rc = amap_insert(amap, &conn->ident, conn, af_allow_system, &aepp); 273 if (rc != EOK) { 274 tcp_conn_delref(conn); 275 fibril_mutex_unlock(&conn_list_lock); 276 return rc; 277 } 278 279 conn->ident = aepp; 252 280 list_append(&conn->link, &conn_list); 253 281 fibril_mutex_unlock(&conn_list_lock); 282 283 return EOK; 254 284 } 255 285 … … 261 291 { 262 292 fibril_mutex_lock(&conn_list_lock); 293 amap_remove(amap, &conn->ident); 263 294 list_remove(&conn->link); 264 295 fibril_mutex_unlock(&conn_list_lock);
Note:
See TracChangeset
for help on using the changeset viewer.