Changeset 004a5fe in mainline for uspace/srv/net/tl/tcp/state.c


Ignore:
Timestamp:
2011-11-20T19:13:53Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eea65f4
Parents:
854e79a6
Message:

Make active OPEN wait for connection establishment (or reset).

File:
1 edited

Legend:

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

    r854e79a6 r004a5fe  
    5858 * connection.
    5959 */
    60 void tcp_uc_open(uint16_t lport, tcp_sock_t *fsock, acpass_t acpass,
     60tcp_error_t tcp_uc_open(uint16_t lport, tcp_sock_t *fsock, acpass_t acpass,
    6161    tcp_conn_t **conn)
    6262{
     
    7777                /* Synchronize (initiate) connection */
    7878                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                }
     93                fibril_mutex_unlock(&nconn->cstate_lock);
     94                log_msg(LVL_DEBUG, "tcp_uc_open: Connection was established.");
    7995        }
    8096
    8197        *conn = nconn;
     98        return TCP_EOK;
    8299}
    83100
Note: See TracChangeset for help on using the changeset viewer.