Changeset e1b4ae0 in mainline for uspace/srv/net/tcp/conn.c
- Timestamp:
- 2017-09-11T07:05:21Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9713b0b
- Parents:
- 975d528
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/conn.c
r975d528 re1b4ae0 59 59 #define TIME_WAIT_TIMEOUT (2*MAX_SEGMENT_LIFETIME) 60 60 61 /** List of all allocated connections */ 61 62 static LIST_INITIALIZE(conn_list); 62 63 /** Taken after tcp_conn_t lock */ 63 64 static FIBRIL_MUTEX_INITIALIZE(conn_list_lock); 65 /** Connection association map */ 64 66 static amap_t *amap; 67 static FIBRIL_MUTEX_INITIALIZE(amap_lock); 65 68 66 69 static void tcp_conn_seg_process(tcp_conn_t *, tcp_segment_t *); … … 85 88 86 89 return EOK; 90 } 91 92 /** Finalize connections. */ 93 void tcp_conns_fini(void) 94 { 95 amap_destroy(amap); 96 amap = NULL; 97 98 assert(list_empty(&conn_list)); 87 99 } 88 100 … … 156 168 if (epp != NULL) 157 169 conn->ident = *epp; 170 171 fibril_mutex_lock(&conn_list_lock); 172 list_append(&conn->link, &conn_list); 173 fibril_mutex_unlock(&conn_list_lock); 158 174 159 175 return conn; … … 192 208 tcp_tqueue_fini(&conn->retransmit); 193 209 210 fibril_mutex_lock(&conn_list_lock); 211 list_remove(&conn->link); 212 fibril_mutex_unlock(&conn_list_lock); 213 194 214 if (conn->rcv_buf != NULL) 195 215 free(conn->rcv_buf); … … 263 283 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_delete(%p)", conn->name, conn); 264 284 285 assert(conn->mapped == false); 265 286 assert(conn->deleted == false); 266 287 conn->deleted = true; … … 280 301 281 302 tcp_conn_addref(conn); 282 fibril_mutex_lock(& conn_list_lock);303 fibril_mutex_lock(&amap_lock); 283 304 284 305 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_add: conn=%p", conn); … … 287 308 if (rc != EOK) { 288 309 tcp_conn_delref(conn); 289 fibril_mutex_unlock(& conn_list_lock);310 fibril_mutex_unlock(&amap_lock); 290 311 return rc; 291 312 } 292 313 293 314 conn->ident = aepp; 294 list_append(&conn->link, &conn_list);295 fibril_mutex_unlock(& conn_list_lock);315 conn->mapped = true; 316 fibril_mutex_unlock(&amap_lock); 296 317 297 318 return EOK; … … 304 325 void tcp_conn_remove(tcp_conn_t *conn) 305 326 { 306 if (! link_used(&conn->link))307 return; 308 309 fibril_mutex_lock(& conn_list_lock);327 if (!conn->mapped) 328 return; 329 330 fibril_mutex_lock(&amap_lock); 310 331 amap_remove(amap, &conn->ident); 311 list_remove(&conn->link);312 fibril_mutex_unlock(& conn_list_lock);332 conn->mapped = false; 333 fibril_mutex_unlock(&amap_lock); 313 334 tcp_conn_delref(conn); 314 335 } … … 400 421 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_find_ref(%p)", epp); 401 422 402 fibril_mutex_lock(& conn_list_lock);423 fibril_mutex_lock(&amap_lock); 403 424 404 425 rc = amap_find_match(amap, epp, &arg); 405 426 if (rc != EOK) { 406 427 assert(rc == ENOENT); 407 fibril_mutex_unlock(& conn_list_lock);428 fibril_mutex_unlock(&amap_lock); 408 429 return NULL; 409 430 } … … 412 433 tcp_conn_addref(conn); 413 434 414 fibril_mutex_unlock(& conn_list_lock);435 fibril_mutex_unlock(&amap_lock); 415 436 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_find_ref: got conn=%p", 416 437 conn); … … 424 445 void tcp_conn_reset(tcp_conn_t *conn) 425 446 { 447 assert(fibril_mutex_is_locked(&conn->lock)); 448 426 449 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_reset()", conn->name); 427 450 conn->reset = true; … … 1223 1246 1224 1247 /* Need to remove and re-insert connection with new identity */ 1225 fibril_mutex_lock(& conn_list_lock);1248 fibril_mutex_lock(&amap_lock); 1226 1249 1227 1250 if (inet_addr_is_any(&conn->ident.remote.addr)) … … 1239 1262 assert(rc == ENOMEM); 1240 1263 log_msg(LOG_DEFAULT, LVL_ERROR, "Out of memory."); 1241 fibril_mutex_unlock(& conn_list_lock);1264 fibril_mutex_unlock(&amap_lock); 1242 1265 tcp_conn_unlock(conn); 1243 1266 return; … … 1245 1268 1246 1269 amap_remove(amap, &oldepp); 1247 fibril_mutex_unlock(& conn_list_lock);1270 fibril_mutex_unlock(&amap_lock); 1248 1271 1249 1272 conn->name = (char *) "a";
Note:
See TracChangeset
for help on using the changeset viewer.