summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c15
-rw-r--r--source3/lib/util.c11
-rw-r--r--source3/lib/util_file.c1
3 files changed, 20 insertions, 7 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 7734328795..eaaa76743a 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -148,6 +148,21 @@ ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *f
}
/*******************************************************************
+A fcntl wrapper that will deal with EINTR.
+********************************************************************/
+
+int sys_fcntl(int fd, int cmd, void *arg)
+{
+ int ret;
+
+ do {
+ errno = 0;
+ ret = fcntl(fd, cmd, arg);
+ } while (ret == -1 && errno == EINTR);
+ return ret;
+}
+
+/*******************************************************************
A stat() wrapper that will deal with 64 bit filesizes.
********************************************************************/
diff --git a/source3/lib/util.c b/source3/lib/util.c
index c524adaa7a..1ee1a9c06a 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -552,13 +552,13 @@ int set_blocking(int fd, BOOL set)
#endif
#endif
- if((val = fcntl(fd, F_GETFL, 0)) == -1)
+ if((val = sys_fcntl(fd, F_GETFL, 0)) == -1)
return -1;
if(set) /* Turn blocking on - ie. clear nonblock flag */
val &= ~FLAG_TO_SET;
else
val |= FLAG_TO_SET;
- return fcntl( fd, F_SETFL, val);
+ return sys_fcntl( fd, F_SETFL, val);
#undef FLAG_TO_SET
}
@@ -620,7 +620,7 @@ ssize_t transfer_file_internal(int infd, int outfd, size_t n, ssize_t (*read_fn)
SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n)
{
- return (SMB_OFF_T)transfer_file_internal(infd, outfd, (size_t)n, read, write);
+ return (SMB_OFF_T)transfer_file_internal(infd, outfd, (size_t)n, sys_read, sys_write);
}
/*******************************************************************
@@ -1353,10 +1353,7 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
lock.l_len = count;
lock.l_pid = 0;
- do {
- errno = 0;
- ret = fcntl(fd,op,&lock);
- } while (ret == -1 && errno == EINTR);
+ ret = sys_fcntl(fd,op,&lock);
if (ret == -1 && errno != 0)
DEBUG(3,("fcntl_lock: fcntl lock gave errno %d (%s)\n",errno,strerror(errno)));
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index e80267f84b..fd3aeb99d9 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -51,6 +51,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
lock.l_pid = 0;
alarm(waitsecs);
+ /* Note we must *NOT* use sys_fcntl here ! JRA */
ret = fcntl(fd, SMB_F_SETLKW, &lock);
alarm(0);
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);