summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c26
-rw-r--r--source3/lib/util.c2
-rw-r--r--source3/lib/util_sock.c4
3 files changed, 21 insertions, 11 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index 2a99ae779e..46b01b747a 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -112,9 +112,7 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
timeout = (tval != NULL) ? (tval->tv_sec * 1000) + (tval->tv_usec/1000) :
-1;
errno = 0;
- do {
- pollrtn = poll( &pfd[0], maxpoll, timeout);
- } while (pollrtn<0 && errno == EINTR);
+ pollrtn = poll( &pfd[0], maxpoll, timeout);
FD_ZERO(fds);
@@ -128,11 +126,9 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
struct timeval t2;
int selrtn;
- do {
- if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
- errno = 0;
- selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
- } while (selrtn<0 && errno == EINTR);
+ if (tval) memcpy((void *)&t2,(void *)tval,sizeof(t2));
+ errno = 0;
+ selrtn = select(maxfd,SELECT_CAST fds,NULL,NULL,tval?&t2:NULL);
return(selrtn);
}
@@ -140,6 +136,20 @@ int sys_select(int maxfd, fd_set *fds,struct timeval *tval)
#endif /* NO_SELECT */
/*******************************************************************
+similar to sys_select() but catch EINTR and continue
+this is what sys_select() used to do in Samba
+********************************************************************/
+int sys_select_intr(int maxfd, fd_set *fds,struct timeval *tval)
+{
+ int ret;
+ do {
+ ret = sys_select(maxfd, fds, tval);
+ } while (ret == -1 && errno == EINTR);
+ return ret;
+}
+
+
+/*******************************************************************
A wrapper for usleep in case we don't have one.
********************************************************************/
diff --git a/source3/lib/util.c b/source3/lib/util.c
index e5aa20a972..f2d89eebb7 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -728,7 +728,7 @@ void msleep(int t)
FD_ZERO(&fds);
errno = 0;
- sys_select(0,&fds,&tval);
+ sys_select_intr(0,&fds,&tval);
GetTimeOfDay(&t2);
tdiff = TvalDiff(&t1,&t2);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index bb62442beb..e6aef16d16 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -241,7 +241,7 @@ static ssize_t read_socket_with_timeout(int fd,char *buf,size_t mincnt,size_t ma
FD_ZERO(&fds);
FD_SET(fd,&fds);
- selrtn = sys_select(fd+1,&fds,&timeout);
+ selrtn = sys_select_intr(fd+1,&fds,&timeout);
/* Check if error */
if(selrtn == -1) {
@@ -345,7 +345,7 @@ ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned
FD_ZERO(&fds);
FD_SET(fd,&fds);
- selrtn = sys_select(fd+1,&fds,&timeout);
+ selrtn = sys_select_intr(fd+1,&fds,&timeout);
if(selrtn <= 0)
return selrtn;