Changeset 004a5fe in mainline for uspace/srv/net/tl/tcp/conn.c
- Timestamp:
- 2011-11-20T19:13:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eea65f4
- Parents:
- 854e79a6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/conn.c
r854e79a6 r004a5fe 111 111 tqueue_inited = true; 112 112 113 /* Connection state change signalling */ 114 fibril_mutex_initialize(&conn->cstate_lock); 115 fibril_condvar_initialize(&conn->cstate_cv); 116 113 117 conn->cstate = st_listen; 114 118 conn->fin_is_acked = false; … … 152 156 } 153 157 158 static void tcp_conn_state_set(tcp_conn_t *conn, tcp_cstate_t nstate) 159 { 160 fibril_mutex_lock(&conn->cstate_lock); 161 conn->cstate = nstate; 162 fibril_condvar_broadcast(&conn->cstate_cv); 163 fibril_mutex_unlock(&conn->cstate_lock); 164 } 165 154 166 /** Synchronize connection. 155 167 * … … 165 177 166 178 tcp_tqueue_ctrl_seg(conn, CTL_SYN); 167 conn->cstate = st_syn_sent;179 tcp_conn_state_set(conn, st_syn_sent); 168 180 } 169 181 … … 179 191 case st_established: 180 192 log_msg(LVL_DEBUG, "FIN sent -> Fin-Wait-1"); 181 conn->cstate = st_fin_wait_1;193 tcp_conn_state_set(conn, st_fin_wait_1); 182 194 break; 183 195 case st_close_wait: 184 196 log_msg(LVL_DEBUG, "FIN sent -> Last-Ack"); 185 conn->cstate = st_last_ack;197 tcp_conn_state_set(conn, st_last_ack); 186 198 break; 187 199 default: … … 328 340 conn->snd_wl2 = seg->seq; 329 341 330 conn->cstate = st_syn_received;342 tcp_conn_state_set(conn, st_syn_received); 331 343 332 344 tcp_tqueue_ctrl_seg(conn, CTL_SYN | CTL_ACK /* XXX */); … … 357 369 log_msg(LVL_DEBUG, "Connection reset. -> Closed"); 358 370 /* XXX Signal user error */ 359 conn->cstate = st_closed;371 tcp_conn_state_set(conn, st_closed); 360 372 /* XXX delete connection */ 361 373 return; … … 397 409 if (seq_no_syn_acked(conn)) { 398 410 log_msg(LVL_DEBUG, " syn acked -> Established"); 399 conn->cstate = st_established;411 tcp_conn_state_set(conn, st_established); 400 412 tcp_tqueue_ctrl_seg(conn, CTL_ACK /* XXX */); 401 413 } else { 402 414 log_msg(LVL_DEBUG, " syn not acked -> Syn-Received"); 403 conn->cstate = st_syn_received;415 tcp_conn_state_set(conn, st_syn_received); 404 416 tcp_tqueue_ctrl_seg(conn, CTL_SYN | CTL_ACK /* XXX */); 405 417 } … … 517 529 log_msg(LVL_DEBUG, "SYN ACKed -> Established"); 518 530 519 conn->cstate = st_established;531 tcp_conn_state_set(conn, st_established); 520 532 521 533 /* XXX Not mentioned in spec?! */ … … 590 602 if (conn->fin_is_acked) { 591 603 log_msg(LVL_DEBUG, " FIN acked -> Fin-Wait-2"); 592 conn->cstate = st_fin_wait_2;604 tcp_conn_state_set(conn, st_fin_wait_2); 593 605 } 594 606 … … 656 668 log_msg(LVL_DEBUG, " FIN acked -> Closed"); 657 669 tcp_conn_remove(conn); 658 conn->cstate = st_closed;670 tcp_conn_state_set(conn, st_closed); 659 671 return cp_done; 660 672 } … … 844 856 case st_established: 845 857 log_msg(LVL_DEBUG, "FIN received -> Close-Wait"); 846 conn->cstate = st_close_wait;858 tcp_conn_state_set(conn, st_close_wait); 847 859 break; 848 860 case st_fin_wait_1: 849 861 log_msg(LVL_DEBUG, "FIN received -> Closing"); 850 conn->cstate = st_closing;862 tcp_conn_state_set(conn, st_closing); 851 863 break; 852 864 case st_fin_wait_2: 853 865 log_msg(LVL_DEBUG, "FIN received -> Time-Wait"); 854 conn->cstate = st_time_wait;866 tcp_conn_state_set(conn, st_time_wait); 855 867 /* Start the Time-Wait timer */ 856 868 tcp_conn_tw_timer_set(conn); … … 980 992 981 993 tcp_conn_remove(conn); 982 conn->cstate = st_closed;994 tcp_conn_state_set(conn, st_closed); 983 995 } 984 996
Note:
See TracChangeset
for help on using the changeset viewer.