Changeset d9ce049 in mainline for uspace/srv/net/tl/tcp/conn.c


Ignore:
Timestamp:
2011-10-04T20:40:05Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8c7a054
Parents:
32105348
Message:

Implement RECEIVE user call.

File:
1 edited

Legend:

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

    r32105348 rd9ce049  
    7070
    7171        /* Allocate receive buffer */
     72        fibril_mutex_initialize(&conn->rcv_buf_lock);
     73        fibril_condvar_initialize(&conn->rcv_buf_cv);
    7274        conn->rcv_buf_size = RCV_BUF_SIZE;
    7375        conn->rcv_buf_used = 0;
     76
    7477        conn->rcv_buf = calloc(1, conn->rcv_buf_size);
    7578        if (conn->rcv_buf == NULL) {
     
    306309        if ((seg->ctrl & CTL_ACK) != 0) {
    307310                conn->snd_una = seg->ack;
    308                 tcp_tqueue_remove_acked(conn);
     311
     312                /*
     313                 * Prune acked segments from retransmission queue and
     314                 * possibly transmit more data.
     315                 */
     316                tcp_tqueue_ack_received(conn);
    309317        }
    310318
     
    459467                /* Update SND.UNA */
    460468                conn->snd_una = seg->ack;
    461 
    462                 /* Prune acked segments from retransmission queue */
    463                 tcp_tqueue_remove_acked(conn);
    464469        }
    465470
     
    468473                conn->snd_wl1 = seg->seq;
    469474                conn->snd_wl2 = seg->ack;
    470         }
     475
     476                log_msg(LVL_DEBUG, "Updating send window, SND.WND=%" PRIu32
     477                    ", SND.WL1=%" PRIu32 ", SND.WL2=%" PRIu32,
     478                    conn->snd_wnd, conn->snd_wl1, conn->snd_wl2);
     479        }
     480
     481        /*
     482         * Prune acked segments from retransmission queue and
     483         * possibly transmit more data.
     484         */
     485        tcp_tqueue_ack_received(conn);
    471486
    472487        return cp_continue;
     
    659674        tcp_conn_trim_seg_to_wnd(conn, seg);
    660675
     676        fibril_mutex_lock(&conn->rcv_buf_lock);
     677
    661678        /* Determine how many bytes to copy */
    662679        text_size = tcp_segment_text_size(seg);
     
    664681
    665682        /* Copy data to receive buffer */
    666         tcp_segment_text_copy(seg, conn->rcv_buf, xfer_size);
     683        tcp_segment_text_copy(seg, conn->rcv_buf + conn->rcv_buf_used,
     684            xfer_size);
     685        conn->rcv_buf_used += xfer_size;
     686
     687        /* Signal to the receive function that new data has arrived */
     688        fibril_condvar_broadcast(&conn->rcv_buf_cv);
     689        fibril_mutex_unlock(&conn->rcv_buf_lock);
    667690
    668691        log_msg(LVL_DEBUG, "Received %zu bytes of data.", xfer_size);
Note: See TracChangeset for help on using the changeset viewer.