Changeset b0d82d1 in mainline


Ignore:
Timestamp:
2011-11-30T21:36:36Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
26ec91c
Parents:
23fe06c
Message:

Implement socket close. Unlock mutexes on error paths.

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/nettest3/nettest3.c

    r23fe06c rb0d82d1  
    9393        } while (rc > 0);
    9494
    95         async_usleep(15*1000*1000);
     95        async_usleep(1000*1000);
    9696
    9797        printf("closesocket()\n");
  • uspace/srv/net/tl/tcp/sock.c

    r23fe06c rb0d82d1  
    553553        socket_core_t *sock_core;
    554554        tcp_sockdata_t *socket;
     555        tcp_error_t trc;
    555556        int rc;
     557        uint8_t buffer[FRAGMENT_SIZE];
     558        size_t data_len;
     559        xflags_t xflags;
    556560
    557561        log_msg(LVL_DEBUG, "tcp_sock_close()");
     
    565569
    566570        socket = (tcp_sockdata_t *)sock_core->specific_data;
    567         (void) socket;
    568         /* XXX Close */
     571        rc = tcp_uc_close(socket->conn);
     572        if (rc != EOK) {
     573                async_answer_0(callid, rc);
     574                return;
     575        }
     576
     577        /* Drain incoming data. This should really be done in the background. */
     578        do {
     579                trc = tcp_uc_receive(socket->conn, buffer, FRAGMENT_SIZE,
     580                    &data_len, &xflags);
     581        } while (trc == TCP_EOK);
    569582
    570583        rc = socket_destroy(net_sess, socket_id, &client->sockets, &gsock,
  • uspace/srv/net/tl/tcp/ucall.c

    r23fe06c rb0d82d1  
    9191
    9292        if (nconn->cstate != st_established) {
     93                fibril_mutex_unlock(&nconn->cstate_lock);
     94
    9395                log_msg(LVL_DEBUG, "tcp_uc_open: Connection was reset.");
    9496                assert(nconn->cstate == st_closed);
     
    163165
    164166        if (conn->rcv_buf_used == 0) {
     167                fibril_mutex_unlock(&conn->rcv_buf_lock);
     168
    165169                /* End of data, peer closed connection. */
    166170                assert(conn->rcv_buf_fin);
Note: See TracChangeset for help on using the changeset viewer.