Changeset e1b4ae0 in mainline
- Timestamp:
- 2017-09-11T07:05:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9713b0b
- Parents:
- 975d528
- Location:
- uspace
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nettl/src/amap.c
r975d528 re1b4ae0 97 97 { 98 98 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_destroy()"); 99 100 assert(list_empty(&map->repla)); 101 assert(list_empty(&map->laddr)); 102 assert(list_empty(&map->llink)); 99 103 free(map); 100 104 } -
uspace/lib/nettl/src/portrng.c
r975d528 re1b4ae0 180 180 * @param pnum Port number 181 181 */ 182 #include <stdio.h> 182 183 void portrng_free_port(portrng_t *pr, uint16_t pnum) 183 184 { 185 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port(%u)", pnum); 184 186 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port() - begin"); 185 187 list_foreach(pr->used, lprng, portrng_port_t, port) { 188 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port - check port %u", port->pn); 186 189 if (port->pn == pnum) { 190 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port - OK"); 187 191 list_remove(&port->lprng); 188 192 free(port); 193 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port() - end"); 189 194 return; 190 195 } 191 196 } 192 197 198 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port - FAIL"); 193 199 assert(false); 194 log_msg(LOG_DEFAULT, LVL_DEBUG2, "portrng_free_port() - end");195 200 } 196 201 -
uspace/srv/net/tcp/Makefile
r975d528 re1b4ae0 57 57 TEST_SOURCES = \ 58 58 $(SOURCES_COMMON) \ 59 test/conn.c \ 59 60 test/iqueue.c \ 60 61 test/main.c \ -
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"; -
uspace/srv/net/tcp/conn.h
r975d528 re1b4ae0 41 41 42 42 extern int tcp_conns_init(void); 43 extern void tcp_conns_fini(void); 43 44 extern tcp_conn_t *tcp_conn_new(inet_ep2_t *); 44 45 extern void tcp_conn_delete(tcp_conn_t *); -
uspace/srv/net/tcp/tcp_type.h
r975d528 re1b4ae0 239 239 /** Connection identification (local and remote endpoint) */ 240 240 inet_ep2_t ident; 241 /** Connection is in association map */ 242 bool mapped; 241 243 242 244 /** Active or passive connection */ … … 369 371 /** TCP client */ 370 372 typedef struct tcp_client { 371 /** Client callbac session */373 /** Client callback session */ 372 374 async_sess_t *sess; 373 375 /** Client's connections */ -
uspace/srv/net/tcp/test/iqueue.c
r975d528 re1b4ae0 56 56 tcp_iqueue_init(&iqueue, conn); 57 57 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 58 PCUT_ASSERT_ INT_EQUALS(ENOENT, rc);58 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 59 59 60 60 tcp_conn_delete(conn); … … 89 89 tcp_iqueue_init(&iqueue, conn); 90 90 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 91 PCUT_ASSERT_ INT_EQUALS(ENOENT, rc);91 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 92 92 93 93 seg->seq = 10; 94 94 tcp_iqueue_insert_seg(&iqueue, seg); 95 95 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 96 PCUT_ASSERT_ INT_EQUALS(EOK, rc);96 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 97 97 98 98 seg->seq = 15; 99 99 tcp_iqueue_insert_seg(&iqueue, seg); 100 100 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 101 PCUT_ASSERT_ INT_EQUALS(ENOENT, rc);101 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 102 102 tcp_iqueue_remove_seg(&iqueue, seg); 103 103 … … 137 137 tcp_iqueue_init(&iqueue, conn); 138 138 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 139 PCUT_ASSERT_ INT_EQUALS(ENOENT, rc);139 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 140 140 141 141 /* Test reception in ascending order */ … … 146 146 147 147 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 148 PCUT_ASSERT_ INT_EQUALS(EOK, rc);148 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 149 149 PCUT_ASSERT_TRUE(rseg == seg1); 150 150 151 151 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 152 PCUT_ASSERT_ INT_EQUALS(EOK, rc);152 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 153 153 PCUT_ASSERT_TRUE(rseg == seg2); 154 154 … … 160 160 161 161 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 162 PCUT_ASSERT_ INT_EQUALS(EOK, rc);163 PCUT_ASSERT_ TRUE(rseg == seg2);162 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 163 PCUT_ASSERT_EQUALS(seg2, rseg); 164 164 165 165 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 166 PCUT_ASSERT_ INT_EQUALS(EOK, rc);167 PCUT_ASSERT_ TRUE(rseg == seg1);166 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 167 PCUT_ASSERT_EQUALS(seg1, rseg); 168 168 169 169 rc = tcp_iqueue_get_ready_seg(&iqueue, &rseg); 170 PCUT_ASSERT_ INT_EQUALS(ENOENT, rc);170 PCUT_ASSERT_ERRNO_VAL(ENOENT, rc); 171 171 172 172 tcp_segment_delete(seg1); -
uspace/srv/net/tcp/test/main.c
r975d528 re1b4ae0 57 57 PCUT_INIT 58 58 59 PCUT_IMPORT(conn); 59 60 PCUT_IMPORT(iqueue); 60 61 PCUT_IMPORT(pdu); -
uspace/srv/net/tcp/test/pdu.c
r975d528 re1b4ae0 62 62 63 63 rc = tcp_pdu_encode(&epp, seg, &pdu); 64 PCUT_ASSERT_ INT_EQUALS(EOK, rc);64 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 65 65 rc = tcp_pdu_decode(pdu, &depp, &dseg); 66 PCUT_ASSERT_ INT_EQUALS(EOK, rc);66 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 67 67 68 68 test_seg_same(seg, dseg); … … 100 100 101 101 rc = tcp_pdu_encode(&epp, seg, &pdu); 102 PCUT_ASSERT_ INT_EQUALS(EOK, rc);102 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 103 103 rc = tcp_pdu_decode(pdu, &depp, &dseg); 104 PCUT_ASSERT_ INT_EQUALS(EOK, rc);104 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 105 105 106 106 test_seg_same(seg, dseg); -
uspace/srv/net/tcp/test/tqueue.c
r975d528 re1b4ae0 57 57 /* We will be calling functions that perform logging */ 58 58 rc = log_init("test-tcp"); 59 PCUT_ASSERT_INT_EQUALS(EOK, rc); 60 } 59 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 60 61 rc = tcp_conns_init(); 62 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 63 } 64 65 PCUT_TEST_AFTER 66 { 67 tcp_conns_fini(); 68 } 69 61 70 62 71 /** Test */ … … 75 84 seg_cnt = 0; 76 85 86 tcp_conn_lock(conn); 87 tcp_conn_reset(conn); 88 tcp_conn_unlock(conn); 77 89 tcp_conn_delete(conn); 78 90 PCUT_ASSERT_EQUALS(0, seg_cnt);
Note:
See TracChangeset
for help on using the changeset viewer.