summaryrefslogtreecommitdiff
path: root/nsswitch/wb_common.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-02-18 13:57:35 +0100
committerVolker Lendecke <vlendec@samba.org>2011-02-28 17:26:18 +0100
commitc1bc916507d4afcf6763fc3ffa651e1ad3a8e931 (patch)
tree798431dfb1da400f424914b380faac2360f6e3c4 /nsswitch/wb_common.c
parentd163f5d67cf461c77749a82b0f83138271ffe333 (diff)
downloadsamba-c1bc916507d4afcf6763fc3ffa651e1ad3a8e931.tar.gz
nsswitch: Eliminate select from wb_common
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Mon Feb 28 17:26:18 CET 2011 on sn-devel-104
Diffstat (limited to 'nsswitch/wb_common.c')
-rw-r--r--nsswitch/wb_common.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
index ccc5142d9c0..2a1795c33bd 100644
--- a/nsswitch/wb_common.c
+++ b/nsswitch/wb_common.c
@@ -22,6 +22,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "replace.h"
+#include "system/select.h"
#include "winbind_client.h"
/* Global variables. These are effectively the client state information */
@@ -233,8 +235,7 @@ static int winbind_named_pipe_sock(const char *dir)
for (wait_time = 0; connect(fd, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) == -1;
wait_time += slept) {
- struct timeval tv;
- fd_set w_fds;
+ struct pollfd pfd;
int ret;
int connect_errno = 0;
socklen_t errnosize;
@@ -244,12 +245,10 @@ static int winbind_named_pipe_sock(const char *dir)
switch (errno) {
case EINPROGRESS:
- FD_ZERO(&w_fds);
- FD_SET(fd, &w_fds);
- tv.tv_sec = CONNECT_TIMEOUT - wait_time;
- tv.tv_usec = 0;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
- ret = select(fd + 1, NULL, &w_fds, NULL, &tv);
+ ret = poll(&pfd, 1, (CONNECT_TIMEOUT - wait_time) * 1000);
if (ret > 0) {
errnosize = sizeof(connect_errno);
@@ -386,24 +385,24 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
nwritten = 0;
while(nwritten < count) {
- struct timeval tv;
- fd_set r_fds;
+ struct pollfd pfd;
+ int ret;
/* Catch pipe close on other end by checking if a read()
- call would not block by calling select(). */
+ call would not block by calling poll(). */
- FD_ZERO(&r_fds);
- FD_SET(winbindd_fd, &r_fds);
- ZERO_STRUCT(tv);
+ pfd.fd = winbindd_fd;
+ pfd.events = POLLIN|POLLHUP;
- if (select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv) == -1) {
+ ret = poll(&pfd, 1, 0);
+ if (ret == -1) {
winbind_close_sock();
- return -1; /* Select error */
+ return -1; /* poll error */
}
/* Write should be OK if fd not available for reading */
- if (FD_ISSET(winbindd_fd, &r_fds)) {
+ if ((ret == 1) && (pfd.revents & (POLLIN|POLLHUP|POLLERR))) {
/* Pipe has closed on remote end */
@@ -436,7 +435,7 @@ static int winbind_write_sock(void *buffer, int count, int recursing,
static int winbind_read_sock(void *buffer, int count)
{
int nread = 0;
- int total_time = 0, selret;
+ int total_time = 0;
if (winbindd_fd == -1) {
return -1;
@@ -444,24 +443,24 @@ static int winbind_read_sock(void *buffer, int count)
/* Read data from socket */
while(nread < count) {
- struct timeval tv;
- fd_set r_fds;
+ struct pollfd pfd;
+ int ret;
/* Catch pipe close on other end by checking if a read()
- call would not block by calling select(). */
+ call would not block by calling poll(). */
+
+ pfd.fd = winbindd_fd;
+ pfd.events = POLLIN|POLLHUP;
- FD_ZERO(&r_fds);
- FD_SET(winbindd_fd, &r_fds);
- ZERO_STRUCT(tv);
/* Wait for 5 seconds for a reply. May need to parameterise this... */
- tv.tv_sec = 5;
- if ((selret = select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv)) == -1) {
+ ret = poll(&pfd, 1, 5000);
+ if (ret == -1) {
winbind_close_sock();
- return -1; /* Select error */
+ return -1; /* poll error */
}
- if (selret == 0) {
+ if (ret == 0) {
/* Not ready for read yet... */
if (total_time >= 30) {
/* Timeout */
@@ -472,7 +471,7 @@ static int winbind_read_sock(void *buffer, int count)
continue;
}
- if (FD_ISSET(winbindd_fd, &r_fds)) {
+ if ((ret == 1) && (pfd.revents & (POLLIN|POLLHUP|POLLERR))) {
/* Do the Read */