Changeset 975d528 in mainline for uspace/srv/net/tcp/conn.c


Ignore:
Timestamp:
2017-09-10T17:48:58Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e1b4ae0
Parents:
12dcd5f
Message:

Add unit tests for TCP tqueue. Fix tqueue possibly being finalized without freeing pending segments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tcp/conn.c

    r12dcd5f r975d528  
    4444#include <stdlib.h>
    4545#include "conn.h"
     46#include "inet.h"
    4647#include "iqueue.h"
     48#include "pdu.h"
    4749#include "segment.h"
    4850#include "seq_no.h"
     
    6264static amap_t *amap;
    6365
    64 static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg);
    65 static void tcp_conn_tw_timer_set(tcp_conn_t *conn);
    66 static void tcp_conn_tw_timer_clear(tcp_conn_t *conn);
     66static void tcp_conn_seg_process(tcp_conn_t *, tcp_segment_t *);
     67static void tcp_conn_tw_timer_set(tcp_conn_t *);
     68static void tcp_conn_tw_timer_clear(tcp_conn_t *);
     69static void tcp_transmit_segment(inet_ep2_t *, tcp_segment_t *);
     70
     71static tcp_tqueue_cb_t tcp_conn_tqueue_cb = {
     72        .transmit_seg = tcp_transmit_segment
     73};
    6774
    6875/** Initialize connections. */
     
    130137
    131138        /* Initialize retransmission queue */
    132         if (tcp_tqueue_init(&conn->retransmit, conn) != EOK)
     139        if (tcp_tqueue_init(&conn->retransmit, conn, &tcp_conn_tqueue_cb)
     140            != EOK) {
    133141                goto error;
     142        }
    134143
    135144        tqueue_inited = true;
     
    295304void tcp_conn_remove(tcp_conn_t *conn)
    296305{
     306        if (!link_used(&conn->link))
     307                return;
     308
    297309        fibril_mutex_lock(&conn_list_lock);
    298310        amap_remove(amap, &conn->ident);
     
    13461358}
    13471359
     1360static void tcp_transmit_segment(inet_ep2_t *epp, tcp_segment_t *seg)
     1361{
     1362        log_msg(LOG_DEFAULT, LVL_DEBUG,
     1363            "tcp_transmit_segment(l:(%u),f:(%u), %p)",
     1364            epp->local.port, epp->remote.port, seg);
     1365
     1366        log_msg(LOG_DEFAULT, LVL_DEBUG, "SEG.SEQ=%" PRIu32 ", SEG.WND=%" PRIu32,
     1367            seg->seq, seg->wnd);
     1368
     1369        tcp_segment_dump(seg);
     1370
     1371//      tcp_rqueue_bounce_seg(sp, seg);
     1372//      tcp_ncsim_bounce_seg(sp, seg);
     1373
     1374        tcp_pdu_t *pdu;
     1375
     1376        if (tcp_pdu_encode(epp, seg, &pdu) != EOK) {
     1377                log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped.");
     1378                return;
     1379        }
     1380
     1381        tcp_transmit_pdu(pdu);
     1382        tcp_pdu_delete(pdu);
     1383}
     1384
    13481385/** Compute flipped endpoint pair for response.
    13491386 *
Note: See TracChangeset for help on using the changeset viewer.