Changeset a4ee3ab2 in mainline for uspace/srv/net/tl/tcp/ucall.c


Ignore:
Timestamp:
2011-11-29T22:51:27Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8fcf74f
Parents:
04cd242
Message:

Implement listen, accept, recvfrom.

File:
1 edited

Legend:

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

    r04cd242 ra4ee3ab2  
    5757 * XXX We should be able to call active open on an existing listening
    5858 * connection.
     59 * XXX We should be able to get connection structure immediately, before
     60 * establishment.
    5961 */
    6062tcp_error_t tcp_uc_open(uint16_t lport, tcp_sock_t *fsock, acpass_t acpass,
     
    7779                /* Synchronize (initiate) connection */
    7880                tcp_conn_sync(nconn);
    79 
    80                 /* Wait for connection to be established or reset */
    81                 log_msg(LVL_DEBUG, "tcp_uc_open: Wait for connection.");
    82                 fibril_mutex_lock(&nconn->cstate_lock);
    83                 while (nconn->cstate == st_syn_sent ||
    84                     nconn->cstate == st_syn_received) {
    85                         fibril_condvar_wait(&nconn->cstate_cv, &nconn->cstate_lock);
    86                 }
    87                 if (nconn->cstate != st_established) {
    88                         log_msg(LVL_DEBUG, "tcp_uc_open: Connection was reset.");
    89                         assert(nconn->cstate == st_closed);
    90                         fibril_mutex_unlock(&nconn->cstate_lock);
    91                         return TCP_ERESET;
    92                 }
     81        }
     82
     83        /* Wait for connection to be established or reset */
     84        log_msg(LVL_DEBUG, "tcp_uc_open: Wait for connection.");
     85        fibril_mutex_lock(&nconn->cstate_lock);
     86        while (nconn->cstate == st_listen ||
     87            nconn->cstate == st_syn_sent ||
     88            nconn->cstate == st_syn_received) {
     89                fibril_condvar_wait(&nconn->cstate_cv, &nconn->cstate_lock);
     90        }
     91
     92        if (nconn->cstate != st_established) {
     93                log_msg(LVL_DEBUG, "tcp_uc_open: Connection was reset.");
     94                assert(nconn->cstate == st_closed);
    9395                fibril_mutex_unlock(&nconn->cstate_lock);
    94                 log_msg(LVL_DEBUG, "tcp_uc_open: Connection was established.");
    95         }
     96                return TCP_ERESET;
     97        }
     98
     99        fibril_mutex_unlock(&nconn->cstate_lock);
     100        log_msg(LVL_DEBUG, "tcp_uc_open: Connection was established.");
    96101
    97102        *conn = nconn;
Note: See TracChangeset for help on using the changeset viewer.