Changeset b99f6e2 in mainline for uspace/srv/net/tcp/service.c
- Timestamp:
- 2015-05-11T16:15:54Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6ff08a0
- Parents:
- 309469de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/service.c
r309469de rb99f6e2 59 59 static void tcp_ev_conn_failed(tcp_cconn_t *); 60 60 static void tcp_ev_conn_reset(tcp_cconn_t *); 61 static void tcp_ev_new_conn(tcp_clst_t *, tcp_cconn_t *); 61 62 62 63 static void tcp_service_cstate_change(tcp_conn_t *, void *, tcp_cstate_t); 63 64 static void tcp_service_recv_data(tcp_conn_t *, void *); 65 static void tcp_service_lst_cstate_change(tcp_conn_t *, void *, tcp_cstate_t); 66 67 static int tcp_cconn_create(tcp_client_t *, tcp_conn_t *, tcp_cconn_t **); 64 68 65 69 static tcp_cb_t tcp_service_cb = { … … 68 72 }; 69 73 74 static tcp_cb_t tcp_service_lst_cb = { 75 .cstate_change = tcp_service_lst_cstate_change, 76 .recv_data = NULL 77 }; 78 70 79 static void tcp_service_cstate_change(tcp_conn_t *conn, void *arg, 71 80 tcp_cstate_t old_state) … … 93 102 } 94 103 104 static void tcp_service_lst_cstate_change(tcp_conn_t *conn, void *arg, 105 tcp_cstate_t old_state) 106 { 107 tcp_cstate_t nstate; 108 tcp_clst_t *clst; 109 tcp_cconn_t *cconn; 110 int rc; 111 tcp_error_t trc; 112 113 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_service_lst_cstate_change()"); 114 nstate = conn->cstate; 115 clst = tcp_uc_get_userptr(conn); 116 117 if ((old_state == st_syn_sent || old_state == st_syn_received) && 118 (nstate == st_established)) { 119 /* Connection established */ 120 clst->conn = NULL; 121 122 rc = tcp_cconn_create(clst->client, conn, &cconn); 123 if (rc != EOK) { 124 /* XXX Could not create client connection */ 125 return; 126 } 127 128 /* XXX Is there a race here (i.e. the connection is already active)? */ 129 tcp_uc_set_cb(conn, &tcp_service_cb, cconn); 130 131 /* New incoming connection */ 132 tcp_ev_new_conn(clst, cconn); 133 } 134 135 if (old_state != st_closed && nstate == st_closed && conn->reset) { 136 /* Connection reset */ 137 /* XXX */ 138 } 139 140 /* XXX Failed to establish connection */ 141 if (0) { 142 /* XXX */ 143 } 144 145 /* Replenish sentinel connection */ 146 147 trc = tcp_uc_open(&clst->elocal, NULL, ap_passive, tcp_open_nonblock, 148 &conn); 149 if (trc != TCP_EOK) { 150 /* XXX Could not replenish connection */ 151 return; 152 } 153 154 clst->conn = conn; 155 156 /* XXX Is there a race here (i.e. the connection is already active)? */ 157 tcp_uc_set_cb(conn, &tcp_service_lst_cb, clst); 158 } 159 95 160 static void tcp_service_recv_data(tcp_conn_t *conn, void *arg) 96 161 { … … 150 215 exch = async_exchange_begin(cconn->client->sess); 151 216 aid_t req = async_send_1(exch, TCP_EV_CONN_RESET, cconn->id, NULL); 217 async_exchange_end(exch); 218 219 async_forget(req); 220 } 221 222 /** New incoming connection */ 223 static void tcp_ev_new_conn(tcp_clst_t *clst, tcp_cconn_t *cconn) 224 { 225 async_exch_t *exch; 226 227 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_ev_new_conn()"); 228 229 exch = async_exchange_begin(clst->client->sess); 230 aid_t req = async_send_2(exch, TCP_EV_NEW_CONN, clst->id, cconn->id, 231 NULL); 152 232 async_exchange_end(exch); 153 233 … … 343 423 local.port = ep->port; 344 424 345 trc = tcp_uc_open(&local, NULL, ap_passive, 0, &conn);425 trc = tcp_uc_open(&local, NULL, ap_passive, tcp_open_nonblock, &conn); 346 426 if (trc != TCP_EOK) 347 427 return EIO; … … 354 434 } 355 435 356 // assoc->cb = &udp_cassoc_cb; 357 // assoc->cb_arg = cassoc; 436 clst->elocal = local; 437 438 /* XXX Is there a race here (i.e. the connection is already active)? */ 439 tcp_uc_set_cb(conn, &tcp_service_lst_cb, clst); 358 440 359 441 *rlst_id = clst->id;
Note:
See TracChangeset
for help on using the changeset viewer.