lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.1-7-g644df52

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd branch master updated. 0.9.1-7-g644df52



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  644df526c13a45b5d5d985ecf3c9fbfd6e6f6d5d (commit)
       via  0787d459f4401363a63ce5582c84ecd5fb7b286f (commit)
      from  07a8170330cd289ee9cba0ce5d579d2695e64b8f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/nss-pam-ldapd/commit/?id=644df526c13a45b5d5d985ecf3c9fbfd6e6f6d5d

commit 644df526c13a45b5d5d985ecf3c9fbfd6e6f6d5d
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sat Aug 31 23:36:27 2013 +0200

    Use normal timeout handling in tio_skipall()
    
    Use the same mechanism in tio_skipall() as in tio_read(), except use a
    different timeout value.

diff --git a/common/tio.c b/common/tio.c
index d68490a..aa032d7 100644
--- a/common/tio.c
+++ b/common/tio.c
@@ -282,9 +282,9 @@ int tio_skip(TFILE *fp, size_t count)
 }
 
 /* Read all available data from the stream and empty the read buffer. */
-int tio_skipall(TFILE *fp, int skiptimeout)
+int tio_skipall(TFILE *fp, int timeout)
 {
-  struct pollfd fds[1];
+  struct timeval deadline = {0, 0};
   int rv;
   size_t len;
   /* clear the read buffer */
@@ -299,17 +299,9 @@ int tio_skipall(TFILE *fp, int skiptimeout)
 #endif /* SSIZE_MAX */
   while (1)
   {
-    /* see if any data is available */
-    fds[0].fd = fp->fd;
-    fds[0].events = POLLIN;
-    rv = poll(fds, 1, skiptimeout);
-    /* check the poll() result */
-    if (rv == 0)
-      return 0; /* no file descriptor ready */
-    if ((rv < 0) && ((errno == EINTR) || (errno == EAGAIN)))
-      continue; /* interrupted, try again */
-    if (rv < 0)
-      return -1; /* something went wrong */
+    /* wait until we have input */
+    if (tio_wait(fp->fd, POLLIN, timeout, &deadline))
+      return -1;
     /* read data from the stream */
     rv = read(fp->fd, fp->readbuffer.buffer, len);
     if (rv == 0)
diff --git a/common/tio.h b/common/tio.h
index 7723ee2..3e0af12 100644
--- a/common/tio.h
+++ b/common/tio.h
@@ -59,7 +59,7 @@ int tio_read(TFILE *fp, void *buf, size_t count);
 int tio_skip(TFILE *fp, size_t count);
 
 /* Read all available data from the stream and empty the read buffer. */
-int tio_skipall(TFILE *fp, int skiptimeout);
+int tio_skipall(TFILE *fp, int timeout);
 
 /* Write the specified buffer to the stream. */
 int tio_write(TFILE *fp, const void *buf, size_t count);

http://arthurdejong.org/git/nss-pam-ldapd/commit/?id=0787d459f4401363a63ce5582c84ecd5fb7b286f

commit 0787d459f4401363a63ce5582c84ecd5fb7b286f
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sat Aug 31 23:05:16 2013 +0200

    Refactor tio_wait()
    
    This changes the function to accept a file descriptor, an event and
    timeout parameter directly instead of a confusing flag.

diff --git a/common/tio.c b/common/tio.c
index f28ac91..d68490a 100644
--- a/common/tio.c
+++ b/common/tio.c
@@ -145,37 +145,27 @@ TFILE *tio_fdopen(int fd, int readtimeout, int 
writetimeout,
 
 /* wait for any activity on the specified file descriptor using
    the specified deadline */
-static int tio_wait(TFILE *fp, int readfd, struct timeval *deadline)
+static int tio_wait(int fd, short events, int timeout,
+                    struct timeval *deadline)
 {
-  int timeout, max_timeout;
+  int t;
   struct pollfd fds[1];
   int rv;
   while (1)
   {
-    /* figure out which values to use */
-    if (readfd)
-    {
-      fds[0].fd = fp->fd;
-      fds[0].events = POLLIN;
-      max_timeout = fp->readtimeout;
-    }
-    else
-    {
-      fds[0].fd = fp->fd;
-      fds[0].events = POLLOUT;
-      max_timeout = fp->writetimeout;
-    }
+    fds[0].fd = fd;
+    fds[0].events = events;
     /* figure out the time we need to wait */
-    if ((timeout = tio_time_remaining(deadline, max_timeout)) < 0)
+    if ((t = tio_time_remaining(deadline, timeout)) < 0)
     {
       errno = ETIME;
       return -1;
     }
     /* sanitiy check for moving clock */
-    if (timeout > max_timeout)
-      timeout = max_timeout;
+    if (t > timeout)
+      t = timeout;
     /* wait for activity */
-    rv = poll(fds, 1, timeout);
+    rv = poll(fds, 1, t);
     if (rv > 0)
       return 0; /* we have activity */
     else if (rv == 0)
@@ -260,7 +250,7 @@ int tio_read(TFILE *fp, void *buf, size_t count)
       }
     }
     /* wait until we have input */
-    if (tio_wait(fp, 1, &deadline))
+    if (tio_wait(fp->fd, POLLIN, fp->readtimeout, &deadline))
       return -1;
     /* read the input in the buffer */
     len = fp->readbuffer.size - fp->readbuffer.start;
@@ -395,7 +385,7 @@ int tio_flush(TFILE *fp)
   while (fp->writebuffer.len > 0)
   {
     /* wait until we can write */
-    if (tio_wait(fp, 0, &deadline))
+    if (tio_wait(fp->fd, POLLOUT, fp->writetimeout, &deadline))
       return -1;
     /* write one block */
     if (tio_writebuf(fp))

-----------------------------------------------------------------------

Summary of changes:
 common/tio.c |   50 ++++++++++++++++----------------------------------
 common/tio.h |    2 +-
 2 files changed, 17 insertions(+), 35 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/