More cancellation points

This commit is contained in:
Gregory Nutt
2016-12-09 15:17:58 -06:00
parent 70de0ee39f
commit 16be9b332e
8 changed files with 83 additions and 27 deletions
+24 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* net/socket/send.c
*
* Copyright (C) 2007-2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,8 @@
#include <sys/socket.h>
#include <errno.h>
#include <nuttx/pthread.h>
#include "tcp/tcp.h"
#include "udp/udp.h"
#include "pkt/pkt.h"
@@ -122,6 +124,10 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
{
int ret;
/* Treat as a cancellation point */
enter_cancellation_point();
switch (psock->s_type)
{
#if defined(CONFIG_NET_PKT)
@@ -192,6 +198,7 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
break;
}
leave_cancellation_point();
return ret;
}
@@ -261,5 +268,20 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
ssize_t send(int sockfd, FAR const void *buf, size_t len, int flags)
{
return psock_send(sockfd_socket(sockfd), buf, len, flags);
FAR struct socket *psock;
ssize_t ret;
/* send() is a cancellation point */
enter_cancellation_point();
/* Get the underlying socket structure */
psock = sockfd_socket(sockfd);
/* And let psock_send do all of the work */
ret = psock_send(psock, buf, len, flags, to, tolen);
leave_cancellation_point();
return ret;
}