Changeset 0edaf0f6 in mainline for uspace/srv/net/tl/tcp/tqueue.c


Ignore:
Timestamp:
2011-12-16T18:04:30Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab9378b4
Parents:
7a8c1c4e
Message:

Revamp connection synchronization.

File:
1 edited

Legend:

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

    r7a8c1c4e r0edaf0f6  
    167167        log_msg(LVL_DEBUG, "%s: tcp_tqueue_new_data()", conn->name);
    168168
    169         fibril_mutex_lock(&conn->snd_buf_lock);
    170 
    171169        /* Number of free sequence numbers in send window */
    172170        avail_wnd = (conn->snd_una + conn->snd_wnd) - conn->snd_nxt;
     
    178176            xfer_seqlen);
    179177
    180         if (xfer_seqlen == 0) {
    181                 fibril_mutex_unlock(&conn->snd_buf_lock);
    182                 return;
    183         }
     178        if (xfer_seqlen == 0)
     179                return;
    184180
    185181        /* XXX Do not always send immediately */
     
    198194        seg = tcp_segment_make_data(ctrl, conn->snd_buf, data_size);
    199195        if (seg == NULL) {
    200                 fibril_mutex_unlock(&conn->snd_buf_lock);
    201196                log_msg(LVL_ERROR, "Memory allocation failure.");
    202197                return;
     
    212207
    213208        fibril_condvar_broadcast(&conn->snd_buf_cv);
    214         fibril_mutex_unlock(&conn->snd_buf_lock);
    215209
    216210        if (send_fin)
     
    323317        log_msg(LVL_DEBUG, "### %s: retransmit_timeout_func(%p)", conn->name, conn);
    324318
     319        fibril_mutex_lock(&conn->lock);
     320
    325321        if (conn->cstate == st_closed) {
    326322                log_msg(LVL_DEBUG, "Connection already closed.");
     323                fibril_mutex_unlock(&conn->lock);
     324                tcp_conn_delref(conn);
    327325                return;
    328326        }
     
    331329        if (link == NULL) {
    332330                log_msg(LVL_DEBUG, "Nothing to retransmit");
     331                fibril_mutex_unlock(&conn->lock);
     332                tcp_conn_delref(conn);
    333333                return;
    334334        }
     
    339339        if (rt_seg == NULL) {
    340340                log_msg(LVL_ERROR, "Memory allocation failed.");
     341                fibril_mutex_unlock(&conn->lock);
     342                tcp_conn_delref(conn);
    341343                /* XXX Handle properly */
    342344                return;
     
    348350        /* Reset retransmission timer */
    349351        tcp_tqueue_timer_set(tqe->conn);
     352
     353        fibril_mutex_unlock(&conn->lock);
     354        tcp_conn_delref(conn);
    350355}
    351356
     
    355360        log_msg(LVL_DEBUG, "### %s: tcp_tqueue_timer_set()", conn->name);
    356361
    357         (void) retransmit_timeout_func;
     362        /* Clear first to make sure we update refcnt correctly */
     363        tcp_tqueue_timer_clear(conn);
     364
     365        tcp_conn_addref(conn);
    358366        fibril_timer_set(conn->retransmit.timer, RETRANSMIT_TIMEOUT,
    359367            retransmit_timeout_func, (void *) conn);
     
    365373        log_msg(LVL_DEBUG, "### %s: tcp_tqueue_timer_clear()", conn->name);
    366374
    367         fibril_timer_clear(conn->retransmit.timer);
     375        if (fibril_timer_clear(conn->retransmit.timer) == fts_active)
     376                tcp_conn_delref(conn);
    368377}
    369378
Note: See TracChangeset for help on using the changeset viewer.