summaryrefslogtreecommitdiff
path: root/source3/lib/packet.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-02-07 16:59:38 +0100
committerVolker Lendecke <vlendec@samba.org>2011-02-28 16:40:19 +0100
commit2b0057c2cb4f05005354008044049fc3dc2bd1fd (patch)
tree6d0ed397c035c325c270f44a166e6b134a974cfe /source3/lib/packet.c
parentdeb58b2e941f6d307f28f7b909f388c39fe915e8 (diff)
downloadsamba-2b0057c2cb4f05005354008044049fc3dc2bd1fd.tar.gz
samba-2b0057c2cb4f05005354008044049fc3dc2bd1fd.tar.bz2
samba-2b0057c2cb4f05005354008044049fc3dc2bd1fd.zip
s3: Eliminate select from packet_fd_read_sync
Diffstat (limited to 'source3/lib/packet.c')
-rw-r--r--source3/lib/packet.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/source3/lib/packet.c b/source3/lib/packet.c
index 1abf35c51a..cce23db551 100644
--- a/source3/lib/packet.c
+++ b/source3/lib/packet.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "../lib/util/select.h"
+#include "system/select.h"
struct packet_context {
int fd;
@@ -102,26 +103,24 @@ NTSTATUS packet_fd_read(struct packet_context *ctx)
return NT_STATUS_OK;
}
-NTSTATUS packet_fd_read_sync(struct packet_context *ctx,
- struct timeval *timeout)
+NTSTATUS packet_fd_read_sync(struct packet_context *ctx, int timeout)
{
- int res;
- fd_set r_fds;
-
- FD_ZERO(&r_fds);
- FD_SET(ctx->fd, &r_fds);
-
- res = sys_select(ctx->fd+1, &r_fds, NULL, NULL, timeout);
+ int res, revents;
+ res = poll_one_fd(ctx->fd, POLLIN|POLLHUP, timeout, &revents);
if (res == 0) {
- DEBUG(10, ("select timed out\n"));
+ DEBUG(10, ("poll timed out\n"));
return NT_STATUS_IO_TIMEOUT;
}
if (res == -1) {
- DEBUG(10, ("select returned %s\n", strerror(errno)));
+ DEBUG(10, ("poll returned %s\n", strerror(errno)));
return map_nt_error_from_unix(errno);
}
+ if ((revents & (POLLIN|POLLHUP|POLLERR)) == 0) {
+ DEBUG(10, ("socket not readable\n"));
+ return NT_STATUS_IO_TIMEOUT;
+ }
return packet_fd_read(ctx);
}