summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-04-19 02:15:10 +0000
committerJeremy Allison <jra@samba.org>2002-04-19 02:15:10 +0000
commite41915d7c802566f598ac844514913fb230f4f7d (patch)
tree57b81ebdc7b6c83851a4b0b663daea4908e995c0 /source3/lib
parent302b581ddc1f9dcee5c1bcb32da558ae2a7b24c1 (diff)
downloadsamba-e41915d7c802566f598ac844514913fb230f4f7d.tar.gz
samba-e41915d7c802566f598ac844514913fb230f4f7d.tar.bz2
samba-e41915d7c802566f598ac844514913fb230f4f7d.zip
Fix send and recvfrom.
Jeremy. (This used to be commit 8cbc24c3bd0e2d2349625c3b5d2e12ac092ec5a8)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c17
-rw-r--r--source3/lib/util_sock.c22
2 files changed, 27 insertions, 12 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index d97751eb4b..61f93dd6a5 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -106,7 +106,7 @@ ssize_t sys_write(int fd, const void *buf, size_t count)
A send wrapper that will deal with EINTR.
********************************************************************/
-int sys_send(int s, const void *msg, size_t len, int flags)
+ssize_t sys_send(int s, const void *msg, size_t len, int flags)
{
ssize_t ret;
@@ -118,6 +118,21 @@ int sys_send(int s, const void *msg, size_t len, int flags)
}
/*******************************************************************
+A recvfrom wrapper that will deal with EINTR.
+********************************************************************/
+
+ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
+{
+ ssize_t ret;
+
+ do {
+ errno = 0;
+ ret = recvfrom(s, buf, len, flags, from, fromlen);
+ } while (ret == -1 && errno == EINTR);
+ return ret;
+}
+
+/*******************************************************************
A stat() wrapper that will deal with 64 bit filesizes.
********************************************************************/
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 1c7f9ce115..27336cefa2 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -42,20 +42,19 @@ int smb_read_error = 0;
BOOL is_a_socket(int fd)
{
- int v,l;
- l = sizeof(int);
- return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
+ int v,l;
+ l = sizeof(int);
+ return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
}
enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON};
-typedef struct smb_socket_option
-{
- char *name;
- int level;
- int option;
- int value;
- int opttype;
+typedef struct smb_socket_option {
+ char *name;
+ int level;
+ int option;
+ int value;
+ int opttype;
} smb_socket_option;
smb_socket_option socket_options[] = {
@@ -97,6 +96,7 @@ smb_socket_option socket_options[] = {
/****************************************************************************
Print socket options.
****************************************************************************/
+
static void print_socket_options(int s)
{
int value, vlen = 4;
@@ -178,7 +178,7 @@ ssize_t read_udp_socket(int fd,char *buf,size_t len)
memset((char *)&sock,'\0',socklen);
memset((char *)&lastip,'\0',sizeof(lastip));
- ret = (ssize_t)recvfrom(fd,buf,len,0,(struct sockaddr *)&sock,&socklen);
+ ret = (ssize_t)sys_recvfrom(fd,buf,len,0,(struct sockaddr *)&sock,&socklen);
if (ret <= 0) {
DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno)));
return(0);