Adds OS internal functions nx_send(), ns_recv(), and nx_recvfrom() which are functionally equivalent to send(), recv(), and recvfrom() except that they do not set the errno variable and do not cause cancellation points.

This commit is contained in:
Gregory Nutt
2017-10-11 09:25:43 -06:00
parent 536e4d7fa6
commit af072d52bc
7 changed files with 287 additions and 221 deletions
+6 -1
View File
@@ -48,6 +48,7 @@
#include <errno.h>
#include <nuttx/cancelpt.h>
#include <nuttx/net/net.h>
#include "inode/inode.h"
@@ -145,7 +146,11 @@ ssize_t read(int fd, FAR void *buf, size_t nbytes)
* the errno variable.
*/
ret = recv(fd, buf, nbytes, 0);
ret = nx_recv(fd, buf, nbytes, 0);
if (ret < 0)
{
goto errout;
}
#else
/* No networking... it is a bad descriptor in any event */
+7 -4
View File
@@ -52,6 +52,7 @@
#endif
#include <nuttx/cancelpt.h>
#include <nuttx/net/net.h>
#include "inode/inode.h"
@@ -167,11 +168,13 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes)
#endif
{
#if defined(CONFIG_NET_TCP) && CONFIG_NSOCKET_DESCRIPTORS > 0
/* Write to a socket descriptor is equivalent to send with flags == 0.
* Note that send() will set the errno on failure.
*/
/* Write to a socket descriptor is equivalent to send with flags == 0. */
ret = send(fd, buf, nbytes, 0);
ret = nx_send(fd, buf, nbytes, 0);
if (ret < 0)
{
goto errout;
}
#else
ret = -EBADF;
goto errout;