Changes in uspace/srv/net/tcp/tqueue.c [7c15d6f:9520af7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/tqueue.c
r7c15d6f r9520af7 43 43 #include <mem.h> 44 44 #include <stdlib.h> 45 45 46 #include "conn.h" 47 #include "inet.h" 46 48 #include "ncsim.h" 47 #include "pdu.h"48 49 #include "rqueue.h" 49 50 #include "segment.h" 50 51 #include "seq_no.h" 51 52 #include "tqueue.h" 52 #include "tcp.h"53 53 #include "tcp_type.h" 54 54 55 55 #define RETRANSMIT_TIMEOUT (2*1000*1000) 56 56 57 static void retransmit_timeout_func(void *arg); 58 static void tcp_tqueue_timer_set(tcp_conn_t *conn); 59 static void tcp_tqueue_timer_clear(tcp_conn_t *conn); 60 61 int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn) 57 static void retransmit_timeout_func(void *); 58 static void tcp_tqueue_timer_set(tcp_conn_t *); 59 static void tcp_tqueue_timer_clear(tcp_conn_t *); 60 static void tcp_tqueue_seg(tcp_conn_t *, tcp_segment_t *); 61 static void tcp_conn_transmit_segment(tcp_conn_t *, tcp_segment_t *); 62 static void tcp_prepare_transmit_segment(tcp_conn_t *, tcp_segment_t *); 63 static void tcp_tqueue_send_immed(tcp_conn_t *, tcp_segment_t *); 64 65 int tcp_tqueue_init(tcp_tqueue_t *tqueue, tcp_conn_t *conn, 66 tcp_tqueue_cb_t *cb) 62 67 { 63 68 tqueue->conn = conn; 64 69 tqueue->timer = fibril_timer_create(&conn->lock); 70 tqueue->cb = cb; 65 71 if (tqueue->timer == NULL) 66 72 return ENOMEM; … … 78 84 void tcp_tqueue_fini(tcp_tqueue_t *tqueue) 79 85 { 86 link_t *link; 87 tcp_tqueue_entry_t *tqe; 88 80 89 if (tqueue->timer != NULL) { 81 90 fibril_timer_destroy(tqueue->timer); 82 91 tqueue->timer = NULL; 83 92 } 93 94 while (!list_empty(&tqueue->list)) { 95 link = list_first(&tqueue->list); 96 tqe = list_get_instance(link, tcp_tqueue_entry_t, link); 97 list_remove(link); 98 99 tcp_segment_delete(tqe->seg); 100 free(tqe); 101 } 84 102 } 85 103 … … 87 105 { 88 106 tcp_segment_t *seg; 107 108 assert(fibril_mutex_is_locked(&conn->lock)); 89 109 90 110 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_tqueue_ctrl_seg(%p, %u)", conn, ctrl); … … 95 115 } 96 116 97 void tcp_tqueue_seg(tcp_conn_t *conn, tcp_segment_t *seg)117 static void tcp_tqueue_seg(tcp_conn_t *conn, tcp_segment_t *seg) 98 118 { 99 119 tcp_segment_t *rt_seg; 100 120 tcp_tqueue_entry_t *tqe; 121 122 assert(fibril_mutex_is_locked(&conn->lock)); 101 123 102 124 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_tqueue_seg(%p, %p)", conn->name, conn, … … 135 157 } 136 158 137 void tcp_prepare_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)159 static void tcp_prepare_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg) 138 160 { 139 161 /* … … 267 289 } 268 290 269 void tcp_conn_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg)291 static void tcp_conn_transmit_segment(tcp_conn_t *conn, tcp_segment_t *seg) 270 292 { 271 293 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_conn_transmit_segment(%p, %p)", … … 279 301 seg->ack = 0; 280 302 281 tcp_t ransmit_segment(&conn->ident, seg);282 } 283 284 void tcp_t ransmit_segment(inet_ep2_t *epp, tcp_segment_t *seg)303 tcp_tqueue_send_immed(conn, seg); 304 } 305 306 void tcp_tqueue_send_immed(tcp_conn_t *conn, tcp_segment_t *seg) 285 307 { 286 308 log_msg(LOG_DEFAULT, LVL_DEBUG, 287 "tcp_t ransmit_segment(l:(%u),f:(%u), %p)",288 epp->local.port, epp->remote.port, seg);309 "tcp_tqueue_send_immed(l:(%u),f:(%u), %p)", 310 conn->ident.local.port, conn->ident.remote.port, seg); 289 311 290 312 log_msg(LOG_DEFAULT, LVL_DEBUG, "SEG.SEQ=%" PRIu32 ", SEG.WND=%" PRIu32, … … 292 314 293 315 tcp_segment_dump(seg); 294 /* 295 tcp_pdu_prepare(conn, seg, &data, &len); 296 tcp_pdu_transmit(data, len); 297 */ 298 // tcp_rqueue_bounce_seg(sp, seg); 299 // tcp_ncsim_bounce_seg(sp, seg); 300 301 tcp_pdu_t *pdu; 302 303 if (tcp_pdu_encode(epp, seg, &pdu) != EOK) { 304 log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped."); 305 return; 306 } 307 308 tcp_transmit_pdu(pdu); 309 tcp_pdu_delete(pdu); 316 317 conn->retransmit.cb->transmit_seg(&conn->ident, seg); 310 318 } 311 319 … … 362 370 static void tcp_tqueue_timer_set(tcp_conn_t *conn) 363 371 { 372 assert(fibril_mutex_is_locked(&conn->lock)); 373 364 374 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_set() begin", conn->name); 365 375 … … 377 387 static void tcp_tqueue_timer_clear(tcp_conn_t *conn) 378 388 { 389 assert(fibril_mutex_is_locked(&conn->lock)); 390 379 391 log_msg(LOG_DEFAULT, LVL_DEBUG, "### %s: tcp_tqueue_timer_clear() begin", conn->name); 380 392
Note:
See TracChangeset
for help on using the changeset viewer.