diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 0e8dfca1ff..226ddd3ffd 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -954,13 +954,9 @@ udgram To use the test: - nsh> mount -t binfs /bin nsh> server & nsh> client - For the sake of sanity, binfs and logins are disabled in this - configuration. - unionfs This is a version of NSH dedicated to performing the simple test diff --git a/configs/sim/userfs/defconfig b/configs/sim/userfs/defconfig index fe11ac5a7f..1d72e540a8 100644 --- a/configs/sim/userfs/defconfig +++ b/configs/sim/userfs/defconfig @@ -16,7 +16,7 @@ CONFIG_DEV_LOOP=y CONFIG_DEV_ZERO=y CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH=y -CONFIG_EXAMPLES_USERFS_STACKSIZE=16384 +CONFIG_EXAMPLES_USERFS_STACKSIZE=8192 CONFIG_EXAMPLES_USERFS=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y @@ -53,4 +53,4 @@ CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_TIME_EXTENDED=y CONFIG_USER_ENTRYPOINT="nsh_main" -CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_USERMAIN_STACKSIZE=8192 diff --git a/net/local/local.h b/net/local/local.h index 6c1427d089..b4ccfd9a8a 100644 --- a/net/local/local.h +++ b/net/local/local.h @@ -51,6 +51,7 @@ #include #include +#include #include #ifdef CONFIG_NET_LOCAL @@ -143,8 +144,8 @@ struct local_conn_s uint8_t lc_proto; /* SOCK_STREAM or SOCK_DGRAM */ uint8_t lc_type; /* See enum local_type_e */ uint8_t lc_state; /* See enum local_state_e */ - int16_t lc_infd; /* File descriptor of read-only FIFO (peers) */ - int16_t lc_outfd; /* File descriptor of write-only FIFO (peers) */ + struct file lc_infile; /* File for read-only FIFO (peers) */ + struct file lc_outfile; /* File descriptor of write-only FIFO (peers) */ char lc_path[UNIX_PATH_MAX]; /* Path assigned by bind() */ int32_t lc_instance_id; /* Connection instance ID for stream * server<->client connection pair */ @@ -424,7 +425,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, * Send a packet on the write-only FIFO. * * Parameters: - * fd File descriptor of write-only FIFO. + * filep File structure of write-only FIFO. * buf Data to send * len Length of data to send * @@ -434,7 +435,8 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, * ****************************************************************************/ -int local_send_packet(int fd, FAR const uint8_t *buf, size_t len); +int local_send_packet(FAR struct file *filep, FAR const uint8_t *buf, + size_t len); /**************************************************************************** * Name: local_recvfrom @@ -475,10 +477,10 @@ ssize_t local_recvfrom(FAR struct socket *psock, FAR void *buf, * Read a data from the read-only FIFO. * * Parameters: - * fd - File descriptor of read-only FIFO. - * buf - Local to store the received data - * len - Length of data to receive [in] - * Length of data actually received [out] + * filep - File structure of write-only FIFO. + * buf - Local to store the received data + * len - Length of data to receive [in] + * Length of data actually received [out] * * Return: * Zero is returned on success; a negated errno value is returned on any @@ -488,7 +490,7 @@ ssize_t local_recvfrom(FAR struct socket *psock, FAR void *buf, * ****************************************************************************/ -int local_fifo_read(int fd, FAR uint8_t *buf, size_t *len); +int local_fifo_read(FAR struct file *filep, FAR uint8_t *buf, size_t *len); /**************************************************************************** * Name: local_getaddr @@ -517,7 +519,7 @@ int local_getaddr(FAR struct local_conn_s *conn, FAR struct sockaddr *addr, * Read a sync bytes until the start of the packet is found. * * Parameters: - * fd - File descriptor of read-only FIFO. + * filep - File structure of write-only FIFO. * * Return: * The non-zero size of the following packet is returned on success; a @@ -525,7 +527,7 @@ int local_getaddr(FAR struct local_conn_s *conn, FAR struct sockaddr *addr, * ****************************************************************************/ -int local_sync(int fd); +int local_sync(FAR struct file *filep); /**************************************************************************** * Name: local_create_fifos diff --git a/net/local/local_accept.c b/net/local/local_accept.c index db70ace1ee..f8fb468ad5 100644 --- a/net/local/local_accept.c +++ b/net/local/local_accept.c @@ -201,7 +201,7 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, if (ret == OK) { - DEBUGASSERT(conn->lc_outfd >= 0); + DEBUGASSERT(conn->lc_outfile.f_inode != NULL); /* Open the server-side read-only FIFO. This should not * block because the client side has already opening it @@ -221,7 +221,7 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr, if (ret == OK) { - DEBUGASSERT(conn->lc_infd >= 0); + DEBUGASSERT(conn->lc_infile.f_inode != NULL); /* Return the address family */ diff --git a/net/local/local_conn.c b/net/local/local_conn.c index ea7c482a60..5ec7f72dc3 100644 --- a/net/local/local_conn.c +++ b/net/local/local_conn.c @@ -91,8 +91,8 @@ FAR struct local_conn_s *local_alloc(void) { /* Initialize non-zero elements the new connection structure */ - conn->lc_infd = -1; - conn->lc_outfd = -1; + conn->lc_infile.f_inode = NULL; + conn->lc_outfile.f_inode = NULL; #ifdef CONFIG_NET_LOCAL_STREAM /* This semaphore is used for signaling and, hence, should not have @@ -126,18 +126,18 @@ void local_free(FAR struct local_conn_s *conn) /* Make sure that the read-only FIFO is closed */ - if (conn->lc_infd >= 0) + if (conn->lc_infile.f_inode != NULL) { - close(conn->lc_infd); - conn->lc_infd = -1; + file_close_detached(&conn->lc_infile); + conn->lc_infile.f_inode = NULL; } /* Make sure that the write-only FIFO is closed */ - if (conn->lc_outfd >= 0) + if (conn->lc_outfile.f_inode != NULL) { - close(conn->lc_outfd); - conn->lc_outfd = -1; + file_close_detached(&conn->lc_outfile); + conn->lc_outfile.f_inode = NULL; } #ifdef CONFIG_NET_LOCAL_STREAM diff --git a/net/local/local_connect.c b/net/local/local_connect.c index c37f5b34fe..9a875b314b 100644 --- a/net/local/local_connect.c +++ b/net/local/local_connect.c @@ -182,7 +182,7 @@ static int inline local_stream_connect(FAR struct local_conn_s *client, goto errout_with_fifos; } - DEBUGASSERT(client->lc_outfd >= 0); + DEBUGASSERT(client->lc_outfile.f_inode != NULL); /* Add ourself to the list of waiting connections and notify the server. */ @@ -225,13 +225,13 @@ static int inline local_stream_connect(FAR struct local_conn_s *client, goto errout_with_outfd; } - DEBUGASSERT(client->lc_infd >= 0); + DEBUGASSERT(client->lc_infile.f_inode != NULL); client->lc_state = LOCAL_STATE_CONNECTED; return OK; errout_with_outfd: - (void)close(client->lc_outfd); - client->lc_outfd = -1; + (void)file_close_detached(&client->lc_outfile); + client->lc_outfile.f_inode = NULL; errout_with_fifos: (void)local_release_fifos(client); diff --git a/net/local/local_fifo.c b/net/local/local_fifo.c index ff53d40024..85d8769816 100644 --- a/net/local/local_fifo.c +++ b/net/local/local_fifo.c @@ -253,9 +253,11 @@ static int local_rx_open(FAR struct local_conn_s *conn, FAR const char *path, bool nonblock) { int oflags = nonblock ? O_RDONLY | O_NONBLOCK : O_RDONLY; + int ret; + int fd; - conn->lc_infd = open(path, oflags); - if (conn->lc_infd < 0) + fd = open(path, oflags); + if (fd < 0) { int errcode = get_errno(); DEBUGASSERT(errcode > 0); @@ -274,6 +276,15 @@ static int local_rx_open(FAR struct local_conn_s *conn, FAR const char *path, return errcode == ENOENT ? -EFAULT : -errcode; } + /* Detach the file descriptor from the open file instance */ + + ret = file_detach(fd, &conn->lc_infile); + if (ret < 0) + { + close(fd); + return ret; + } + return OK; } @@ -289,9 +300,11 @@ static int local_tx_open(FAR struct local_conn_s *conn, FAR const char *path, bool nonblock) { int oflags = nonblock ? O_WRONLY | O_NONBLOCK : O_WRONLY; + int ret; + int fd; - conn->lc_outfd = open(path, oflags); - if (conn->lc_outfd < 0) + fd = open(path, oflags); + if (fd < 0) { int errcode = get_errno(); DEBUGASSERT(errcode > 0); @@ -310,6 +323,15 @@ static int local_tx_open(FAR struct local_conn_s *conn, FAR const char *path, return errcode == ENOENT ? -EFAULT : -errcode; } + /* Detach the file descriptor from the open file instance */ + + ret = file_detach(fd, &conn->lc_outfile); + if (ret < 0) + { + close(fd); + return ret; + } + return OK; } @@ -324,23 +346,19 @@ static int local_tx_open(FAR struct local_conn_s *conn, FAR const char *path, * ****************************************************************************/ -static int local_set_policy(int fd, unsigned long policy) +static int local_set_policy(FAR struct file *filep, unsigned long policy) { int ret; /* Set the buffer policy */ - ret = ioctl(fd, PIPEIOC_POLICY, policy); + ret = file_ioctl(filep, PIPEIOC_POLICY, policy); if (ret < 0) { - int errcode = get_errno(); - DEBUGASSERT(errcode > 0); - - nerr("ERROR: Failed to set FIFO buffer policty: %d\n", errcode); - return -errcode; + nerr("ERROR: Failed to set FIFO buffer policty: %d\n", ret); } - return OK; + return ret; } /**************************************************************************** @@ -492,7 +510,7 @@ int local_open_client_rx(FAR struct local_conn_s *client, bool nonblock) { /* Policy: Free FIFO resources when the last reference is closed */ - ret = local_set_policy(client->lc_infd, 0); + ret = local_set_policy(&client->lc_infile, 0); } return ret; @@ -524,7 +542,7 @@ int local_open_client_tx(FAR struct local_conn_s *client, bool nonblock) { /* Policy: Free FIFO resources when the last reference is closed */ - ret = local_set_policy(client->lc_outfd, 0); + ret = local_set_policy(&client->lc_outfile, 0); } return ret; @@ -556,7 +574,7 @@ int local_open_server_rx(FAR struct local_conn_s *server, bool nonblock) { /* Policy: Free FIFO resources when the last reference is closed */ - ret = local_set_policy(server->lc_infd, 0); + ret = local_set_policy(&server->lc_infile, 0); } return ret; @@ -588,7 +606,7 @@ int local_open_server_tx(FAR struct local_conn_s *server, bool nonblock) { /* Policy: Free FIFO resources when the last reference is closed */ - ret = local_set_policy(server->lc_outfd, 0); + ret = local_set_policy(&server->lc_outfile, 0); } return ret; @@ -620,7 +638,7 @@ int local_open_receiver(FAR struct local_conn_s *conn, bool nonblock) { /* Policy: Free FIFO resources when the buffer is empty. */ - ret = local_set_policy(conn->lc_infd, 1); + ret = local_set_policy(&conn->lc_infile, 1); } return ret; @@ -653,7 +671,7 @@ int local_open_sender(FAR struct local_conn_s *conn, FAR const char *path, { /* Policy: Free FIFO resources when the buffer is empty. */ - ret = local_set_policy(conn->lc_outfd, 1); + ret = local_set_policy(&conn->lc_outfile, 1); } return ret; diff --git a/net/local/local_netpoll.c b/net/local/local_netpoll.c index a8d1c0ca04..81aff7c051 100644 --- a/net/local/local_netpoll.c +++ b/net/local/local_netpoll.c @@ -208,7 +208,8 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Poll wants to check state for both input and output. */ - if (conn->lc_infd < 0 || conn->lc_outfd < 0) + if (conn->lc_infile.f_inode == NULL || + conn->lc_outfile.f_inode == NULL) { fds->priv = NULL; goto pollerr; @@ -222,23 +223,23 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) return -ENOMEM; } - shadowfds[0].fd = conn->lc_infd; - shadowfds[0].sem = fds->sem; + shadowfds[0].fd = 0; /* Does not matter */ + shadowfds[0].sem = fds->sem; shadowfds[0].events = fds->events & ~POLLOUT; - shadowfds[1].fd = conn->lc_outfd; - shadowfds[1].sem = fds->sem; + shadowfds[1].fd = 1; /* Does not matter */ + shadowfds[1].sem = fds->sem; shadowfds[1].events = fds->events & ~POLLIN; /* Setup poll for both shadow pollfds. */ - ret = fdesc_poll(conn->lc_infd, &shadowfds[0], true); + ret = file_poll(&conn->lc_infile, &shadowfds[0], true); if (ret >= 0) { - ret = fdesc_poll(conn->lc_outfd, &shadowfds[1], true); + ret = file_poll(&conn->lc_outfile, &shadowfds[1], true); if (ret < 0) { - (void)fdesc_poll(conn->lc_infd, &shadowfds[0], false); + (void)file_poll(&conn->lc_infile, &shadowfds[0], false); } } @@ -260,13 +261,13 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) { /* Poll wants to check state for input only. */ - if (conn->lc_infd < 0) + if (conn->lc_infile.f_inode == NULL) { fds->priv = NULL; goto pollerr; } - ret = fdesc_poll(conn->lc_infd, fds, true); + ret = file_poll(&conn->lc_infile, fds, true); } break; @@ -274,13 +275,13 @@ int local_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) { /* Poll wants to check state for output only. */ - if (conn->lc_outfd < 0) + if (conn->lc_outfile.f_inode == NULL) { fds->priv = NULL; goto pollerr; } - ret = fdesc_poll(conn->lc_outfd, fds, true); + ret = file_poll(&conn->lc_outfile, fds, true); } break; @@ -350,18 +351,15 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) return OK; } - DEBUGASSERT(shadowfds[0].fd == conn->lc_infd); - DEBUGASSERT(shadowfds[1].fd == conn->lc_outfd); - /* Teardown for both shadow pollfds. */ - ret = fdesc_poll(conn->lc_infd, &shadowfds[0], false); + ret = file_poll(&conn->lc_infile, &shadowfds[0], false); if (ret < 0) { status = ret; } - ret = fdesc_poll(conn->lc_outfd, &shadowfds[1], false); + ret = file_poll(&conn->lc_outfile, &shadowfds[1], false); if (ret < 0) { status = ret; @@ -380,7 +378,7 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) return OK; } - status = fdesc_poll(conn->lc_infd, fds, false); + status = file_poll(&conn->lc_infile, fds, false); } break; @@ -391,7 +389,7 @@ int local_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds) return OK; } - status = fdesc_poll(conn->lc_outfd, fds, false); + status = file_poll(&conn->lc_outfile, fds, false); } break; diff --git a/net/local/local_recvfrom.c b/net/local/local_recvfrom.c index f9de54d6d1..389739e190 100644 --- a/net/local/local_recvfrom.c +++ b/net/local/local_recvfrom.c @@ -79,7 +79,7 @@ static int psock_fifo_read(FAR struct socket *psock, FAR void *buf, FAR struct local_conn_s *conn = (FAR struct local_conn_s *)psock->s_conn; int ret; - ret = local_fifo_read(conn->lc_infd, buf, readlen); + ret = local_fifo_read(&conn->lc_infile, buf, readlen); if (ret < 0) { /* -ECONNRESET is a special case. We may or not have received @@ -161,7 +161,7 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* The incoming FIFO should be open */ - DEBUGASSERT(conn->lc_infd >= 0); + DEBUGASSERT(conn->lc_infile.f_inode != NULL); /* Are there still bytes in the FIFO from the last packet? */ @@ -171,7 +171,7 @@ psock_stream_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * the size of the next packet. */ - ret = local_sync(conn->lc_infd); + ret = local_sync(&conn->lc_infile); if (ret < 0) { nerr("ERROR: Failed to get packet length: %d\n", ret); @@ -265,7 +265,7 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* The incoming FIFO should not be open */ - DEBUGASSERT(conn->lc_infd < 0); + DEBUGASSERT(conn->lc_infile.f_inode == NULL); /* Make sure that half duplex FIFO has been created */ @@ -292,7 +292,7 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * the next packet. */ - ret = local_sync(conn->lc_infd); + ret = local_sync(&conn->lc_infile); if (ret < 0) { nerr("ERROR: Failed to get packet length: %d\n", ret); @@ -348,8 +348,8 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* Now we can close the read-only file descriptor */ - close(conn->lc_infd); - conn->lc_infd = -1; + file_close_detached(&conn->lc_infile); + conn->lc_infile.f_inode = NULL; /* Release our reference to the half duplex FIFO */ @@ -371,8 +371,8 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, errout_with_infd: /* Close the read-only file descriptor */ - close(conn->lc_infd); - conn->lc_infd = -1; + file_close_detached(&conn->lc_infile); + conn->lc_infile.f_inode = NULL; errout_with_halfduplex: /* Release our reference to the half duplex FIFO */ diff --git a/net/local/local_recvutils.c b/net/local/local_recvutils.c index 5abf574832..91e185754f 100644 --- a/net/local/local_recvutils.c +++ b/net/local/local_recvutils.c @@ -64,10 +64,10 @@ * Read a data from the read-only FIFO. * * Parameters: - * fd - File descriptor of read-only FIFO. - * buf - Local to store the received data - * len - Length of data to receive [in] - * Length of data actually received [out] + * filep - File structure of write-only FIFO. + * buf - Local to store the received data + * len - Length of data to receive [in] + * Length of data actually received [out] * * Return: * Zero is returned on success; a negated errno value is returned on any @@ -77,7 +77,7 @@ * ****************************************************************************/ -int local_fifo_read(int fd, FAR uint8_t *buf, size_t *len) +int local_fifo_read(FAR struct file *filep, FAR uint8_t *buf, size_t *len) { ssize_t remaining; ssize_t nread; @@ -88,7 +88,7 @@ int local_fifo_read(int fd, FAR uint8_t *buf, size_t *len) remaining = *len; while (remaining > 0) { - nread = nx_read(fd, buf, remaining); + nread = file_read(filep, buf, remaining); if (nread < 0) { if (nread != -EINTR) @@ -131,7 +131,7 @@ errout: * Read a sync bytes until the start of the packet is found. * * Parameters: - * fd - File descriptor of read-only FIFO. + * filep - File structure of write-only FIFO. * * Return: * The non-zero size of the following packet is returned on success; a @@ -139,7 +139,7 @@ errout: * ****************************************************************************/ -int local_sync(int fd) +int local_sync(FAR struct file *filep) { size_t readlen; uint16_t pktlen; @@ -157,7 +157,7 @@ int local_sync(int fd) do { readlen = sizeof(uint8_t); - ret = local_fifo_read(fd, &sync, &readlen); + ret = local_fifo_read(filep, &sync, &readlen); if (ret < 0) { nerr("ERROR: Failed to read sync bytes: %d\n", ret); @@ -171,7 +171,7 @@ int local_sync(int fd) do { readlen = sizeof(uint8_t); - ret = local_fifo_read(fd, &sync, &readlen); + ret = local_fifo_read(filep, &sync, &readlen); if (ret < 0) { nerr("ERROR: Failed to read sync bytes: %d\n", ret); @@ -185,7 +185,7 @@ int local_sync(int fd) /* Then read the packet length */ readlen = sizeof(uint16_t); - ret = local_fifo_read(fd, (FAR uint8_t *)&pktlen, &readlen); + ret = local_fifo_read(filep, (FAR uint8_t *)&pktlen, &readlen); return ret < 0 ? ret : pktlen; } diff --git a/net/local/local_send.c b/net/local/local_send.c index 4d37cbd9cc..a305dac441 100644 --- a/net/local/local_send.c +++ b/net/local/local_send.c @@ -87,7 +87,7 @@ ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf, */ if (peer->lc_state != LOCAL_STATE_CONNECTED || - peer->lc_outfd < 0) + peer->lc_outfile.f_inode == NULL) { nerr("ERROR: not connected\n"); return -ENOTCONN; @@ -95,7 +95,7 @@ ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf, /* Send the packet */ - ret = local_send_packet(peer->lc_outfd, (FAR uint8_t *)buf, len); + ret = local_send_packet(&peer->lc_outfile, (FAR uint8_t *)buf, len); /* If the send was successful, then the full packet will have been sent */ diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c index e8491db58e..fad305fd0b 100644 --- a/net/local/local_sendpacket.c +++ b/net/local/local_sendpacket.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/local/local_sendpacket.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -79,7 +79,7 @@ static const uint8_t g_preamble[LOCAL_PREAMBLE_SIZE] = * Write a data on the write-only FIFO. * * Parameters: - * fd File descriptor of write-only FIFO. + * filep File structure of write-only FIFO. * buf Data to send * len Length of data to send * @@ -89,13 +89,14 @@ static const uint8_t g_preamble[LOCAL_PREAMBLE_SIZE] = * ****************************************************************************/ -static int local_fifo_write(int fd, FAR const uint8_t *buf, size_t len) +static int local_fifo_write(FAR struct file *filep, FAR const uint8_t *buf, + size_t len) { ssize_t nwritten; while (len > 0) { - nwritten = nx_write(fd, buf, len); + nwritten = file_write(filep, buf, len); if (nwritten < 0) { if (nwritten != -EINTR) @@ -128,7 +129,7 @@ static int local_fifo_write(int fd, FAR const uint8_t *buf, size_t len) * Send a packet on the write-only FIFO. * * Parameters: - * fd File descriptor of write-only FIFO. + * filep File structure of write-only FIFO. * buf Data to send * len Length of data to send * @@ -138,25 +139,27 @@ static int local_fifo_write(int fd, FAR const uint8_t *buf, size_t len) * ****************************************************************************/ -int local_send_packet(int fd, FAR const uint8_t *buf, size_t len) +int local_send_packet(FAR struct file *filep, FAR const uint8_t *buf, + size_t len) { uint16_t len16; int ret; /* Send the packet preamble */ - ret = local_fifo_write(fd, g_preamble, LOCAL_PREAMBLE_SIZE); + ret = local_fifo_write(filep, g_preamble, LOCAL_PREAMBLE_SIZE); if (ret == OK) { /* Send the packet length */ len16 = len; - ret = local_fifo_write(fd, (FAR const uint8_t *)&len16, sizeof(uint16_t)); + ret = local_fifo_write(filep, (FAR const uint8_t *)&len16, + sizeof(uint16_t)); if (ret == OK) { /* Send the packet data */ - ret = local_fifo_write(fd, buf, len); + ret = local_fifo_write(filep, buf, len); } } diff --git a/net/local/local_sendto.c b/net/local/local_sendto.c index de59ee34f9..ec7509a0ec 100644 --- a/net/local/local_sendto.c +++ b/net/local/local_sendto.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/local/local_sendto.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -112,7 +112,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, /* The outgoing FIFO should not be open */ - DEBUGASSERT(conn->lc_outfd < 0); + DEBUGASSERT(conn->lc_outfile.f_inode == 0); /* At present, only standard pathname type address are support */ @@ -150,7 +150,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, /* Send the packet */ - nsent = local_send_packet(conn->lc_outfd, buf, len); + nsent = local_send_packet(&conn->lc_outfile, buf, len); if (nsent < 0) { nerr("ERROR: Failed to send the packet: %d\n", ret); @@ -164,8 +164,8 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf, /* Now we can close the write-only socket descriptor */ - close(conn->lc_outfd); - conn->lc_outfd = -1; + file_close_detached(&conn->lc_outfile); + conn->lc_outfile.f_inode = NULL; errout_with_halfduplex: /* Release our reference to the half duplex FIFO */