net/sockets: psock_sendto() is an internal OS interface an should not set the errno variable.
This commit is contained in:
parent
8a75add6a0
commit
9e8529b1d0
@ -162,12 +162,12 @@ static int rpcclnt_send(FAR struct rpcclnt *rpc, int procid, int prog,
|
|||||||
FAR void *call, int reqlen)
|
FAR void *call, int reqlen)
|
||||||
{
|
{
|
||||||
ssize_t nbytes;
|
ssize_t nbytes;
|
||||||
int error = OK;
|
int ret = OK;
|
||||||
|
|
||||||
/* Send the call message
|
/* Send the call message
|
||||||
*
|
*
|
||||||
* On success, psock_sendto returns the number of bytes sent;
|
* On success, psock_sendto returns the number of bytes sent;
|
||||||
* On failure, it returns -1 with the specific error in errno.
|
* On failure, it returns a negated errno value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nbytes = psock_sendto(rpc->rc_so, call, reqlen, 0,
|
nbytes = psock_sendto(rpc->rc_so, call, reqlen, 0,
|
||||||
@ -176,11 +176,11 @@ static int rpcclnt_send(FAR struct rpcclnt *rpc, int procid, int prog,
|
|||||||
{
|
{
|
||||||
/* psock_sendto failed */
|
/* psock_sendto failed */
|
||||||
|
|
||||||
error = get_errno();
|
ret = (int)-nbytes;
|
||||||
ferr("ERROR: psock_sendto failed: %d\n", error);
|
ferr("ERROR: psock_sendto failed: %d\n", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -775,8 +775,8 @@ ssize_t psock_send(FAR struct socket *psock, const void *buf, size_t len,
|
|||||||
* tolen The length of the address structure
|
* tolen The length of the address structure
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On a negated errno
|
||||||
* -1 is returned, and errno is set appropriately:
|
* value is returned. One of:
|
||||||
*
|
*
|
||||||
* EAGAIN or EWOULDBLOCK
|
* EAGAIN or EWOULDBLOCK
|
||||||
* The socket is marked non-blocking and the requested operation
|
* The socket is marked non-blocking and the requested operation
|
||||||
@ -818,8 +818,6 @@ ssize_t psock_send(FAR struct socket *psock, const void *buf, size_t len,
|
|||||||
* In this case the process will also receive a SIGPIPE unless
|
* In this case the process will also receive a SIGPIPE unless
|
||||||
* MSG_NOSIGNAL is set.
|
* MSG_NOSIGNAL is set.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||||
|
@ -73,8 +73,8 @@
|
|||||||
* tolen The length of the address structure
|
* tolen The length of the address structure
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On a negated errno
|
||||||
* -1 is returned, and errno is set appropriately:
|
* value is returned. One of:
|
||||||
*
|
*
|
||||||
* EAGAIN or EWOULDBLOCK
|
* EAGAIN or EWOULDBLOCK
|
||||||
* The socket is marked non-blocking and the requested operation
|
* The socket is marked non-blocking and the requested operation
|
||||||
@ -116,8 +116,6 @@
|
|||||||
* In this case the process will also receive a SIGPIPE unless
|
* In this case the process will also receive a SIGPIPE unless
|
||||||
* MSG_NOSIGNAL is set.
|
* MSG_NOSIGNAL is set.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||||
@ -125,7 +123,6 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
socklen_t tolen)
|
socklen_t tolen)
|
||||||
{
|
{
|
||||||
ssize_t nsent;
|
ssize_t nsent;
|
||||||
int errcode;
|
|
||||||
|
|
||||||
DEBUGASSERT(psock != NULL && buf != NULL);
|
DEBUGASSERT(psock != NULL && buf != NULL);
|
||||||
|
|
||||||
@ -140,8 +137,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
return psock_send(psock, buf, len, flags);
|
return psock_send(psock, buf, len, flags);
|
||||||
#else
|
#else
|
||||||
nerr("ERROR: No 'to' address\n");
|
nerr("ERROR: No 'to' address\n");
|
||||||
errcode = EINVAL;
|
return -EINVAL;
|
||||||
goto errout;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,8 +146,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
if (psock == NULL || psock->s_crefs <= 0)
|
if (psock == NULL || psock->s_crefs <= 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Invalid socket\n");
|
nerr("ERROR: Invalid socket\n");
|
||||||
errcode = EBADF;
|
return -EBADF;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the address family's sendto() method handle the operation */
|
/* Let the address family's sendto() method handle the operation */
|
||||||
@ -164,15 +159,10 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
if (nsent < 0)
|
if (nsent < 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Family-specific send failed: %ld\n", (long)nsent);
|
nerr("ERROR: Family-specific send failed: %ld\n", (long)nsent);
|
||||||
errcode = -nsent;
|
return nsent;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nsent;
|
return nsent;
|
||||||
|
|
||||||
errout:
|
|
||||||
set_errno(errcode);
|
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -236,8 +226,6 @@ errout:
|
|||||||
* In this case the process will also receive a SIGPIPE unless
|
* In this case the process will also receive a SIGPIPE unless
|
||||||
* MSG_NOSIGNAL is set.
|
* MSG_NOSIGNAL is set.
|
||||||
*
|
*
|
||||||
* Assumptions:
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
|
ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
|
||||||
@ -257,6 +245,12 @@ ssize_t sendto(int sockfd, FAR const void *buf, size_t len, int flags,
|
|||||||
/* And let psock_sendto do all of the work */
|
/* And let psock_sendto do all of the work */
|
||||||
|
|
||||||
ret = psock_sendto(psock, buf, len, flags, to, tolen);
|
ret = psock_sendto(psock, buf, len, flags, to, tolen);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
set_errno((int)-ret);
|
||||||
|
ret = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
leave_cancellation_point();
|
leave_cancellation_point();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user