diff options
author | Volker Lendecke <vl@samba.org> | 2011-02-08 17:57:12 +0100 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2011-02-28 16:40:19 +0100 |
commit | a2970dfaef9ceac6af2784cbffe9e2d8ac14b188 (patch) | |
tree | 8d5cac552ed2289661577cfaaa5b5e1f9febb835 | |
parent | e6f820835874e6bbf103768665952b7884cd8452 (diff) | |
download | samba-a2970dfaef9ceac6af2784cbffe9e2d8ac14b188.tar.gz samba-a2970dfaef9ceac6af2784cbffe9e2d8ac14b188.tar.bz2 samba-a2970dfaef9ceac6af2784cbffe9e2d8ac14b188.zip |
s3: Eliminate sys_select_intr from read_fd_with_timeout
-rw-r--r-- | source3/lib/util_sock.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 51de68f4c3..73b69b4440 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -446,11 +446,9 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf, unsigned int time_out, size_t *size_ret) { - fd_set fds; - int selrtn; + int pollrtn; ssize_t readret; size_t nread = 0; - struct timeval timeout; /* just checking .... */ if (maxcnt <= 0) @@ -485,23 +483,20 @@ NTSTATUS read_fd_with_timeout(int fd, char *buf, system performance will suffer severely as select always returns true on disk files */ - /* Set initial timeout */ - timeout.tv_sec = (time_t)(time_out / 1000); - timeout.tv_usec = (long)(1000 * (time_out % 1000)); - for (nread=0; nread < mincnt; ) { - FD_ZERO(&fds); - FD_SET(fd,&fds); + int revents; - selrtn = sys_select_intr(fd+1,&fds,NULL,NULL,&timeout); + pollrtn = poll_intr_one_fd(fd, POLLIN|POLLHUP, time_out, + &revents); /* Check if error */ - if (selrtn == -1) { + if (pollrtn == -1) { return map_nt_error_from_unix(errno); } /* Did we timeout ? */ - if (selrtn == 0) { + if ((pollrtn == 0) || + ((revents & (POLLIN|POLLHUP|POLLERR)) == 0)) { DEBUG(10,("read_fd_with_timeout: timeout read. " "select timed out.\n")); return NT_STATUS_IO_TIMEOUT; |