Blame SOURCES/nss-pam-ldapd-0.8.12-Use-a-timeout-when-skipping-remaining-result-data.patch

bdd351
From 335f7e085b45556276d2c1f224648a7eed28e4fd Mon Sep 17 00:00:00 2001
bdd351
From: Arthur de Jong <arthur@arthurdejong.org>
bdd351
Date: Sun, 6 Oct 2013 14:11:51 +0000
bdd351
Subject: [PATCH 2/3] use a timeout when skipping remaining result data
bdd351
 (c9e2f97 from 0.9)
bdd351
bdd351
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-0.8@2031 ef36b2f9-881f-0410-afb5-c4e39611909c
bdd351
---
bdd351
 common/tio.c |  6 +++---
bdd351
 common/tio.h |  4 ++--
bdd351
 nss/common.h | 10 +++++++---
bdd351
 3 files changed, 12 insertions(+), 8 deletions(-)
bdd351
bdd351
diff --git a/common/tio.c b/common/tio.c
bdd351
index 9aef80ca91faedad8f75e09b9070d22ed4a0878d..780ea38f175482dfed5e1c754ef75e93ffd83768 100644
bdd351
--- a/common/tio.c
bdd351
+++ b/common/tio.c
bdd351
@@ -2,7 +2,7 @@
bdd351
    tio.c - timed io functions
bdd351
    This file is part of the nss-pam-ldapd library.
bdd351
 
bdd351
-   Copyright (C) 2007, 2008, 2010, 2011, 2012 Arthur de Jong
bdd351
+   Copyright (C) 2007, 2008, 2010, 2011, 2012, 2013 Arthur de Jong
bdd351
 
bdd351
    This library is free software; you can redistribute it and/or
bdd351
    modify it under the terms of the GNU Lesser General Public
bdd351
@@ -298,7 +298,7 @@ int tio_skip(TFILE *fp, size_t count)
bdd351
 }
bdd351
 
bdd351
 /* Read all available data from the stream and empty the read buffer. */
bdd351
-int tio_skipall(TFILE *fp)
bdd351
+int tio_skipall(TFILE *fp,int skiptimeout)
bdd351
 {
bdd351
   struct pollfd fds[1];
bdd351
   int rv;
bdd351
@@ -318,7 +318,7 @@ int tio_skipall(TFILE *fp)
bdd351
     /* see if any data is available */
bdd351
     fds[0].fd=fp->fd;
bdd351
     fds[0].events=POLLIN;
bdd351
-    rv=poll(fds,1,0);
bdd351
+    rv=poll(fds,1,skiptimeout);
bdd351
     /* check the poll() result */
bdd351
     if (rv==0)
bdd351
       return 0; /* no file descriptor ready */
bdd351
diff --git a/common/tio.h b/common/tio.h
bdd351
index cd3f370732e4c54815187bb8012fd5a5ff8972af..b38d458aedd660ff95ff2e57f9df790ffd51ff6d 100644
bdd351
--- a/common/tio.h
bdd351
+++ b/common/tio.h
bdd351
@@ -2,7 +2,7 @@
bdd351
    tio.h - timed io functions
bdd351
    This file is part of the nss-pam-ldapd library.
bdd351
 
bdd351
-   Copyright (C) 2007, 2008, 2010, 2012 Arthur de Jong
bdd351
+   Copyright (C) 2007, 2008, 2010, 2012, 2013 Arthur de Jong
bdd351
 
bdd351
    This library is free software; you can redistribute it and/or
bdd351
    modify it under the terms of the GNU Lesser General Public
bdd351
@@ -59,7 +59,7 @@ int tio_read(TFILE *fp,void *buf,size_t count);
bdd351
 int tio_skip(TFILE *fp,size_t count);
bdd351
 
bdd351
 /* Read all available data from the stream and empty the read buffer. */
bdd351
-int tio_skipall(TFILE *fp);
bdd351
+int tio_skipall(TFILE *fp,int skiptimeout);
bdd351
 
bdd351
 /* Write the specified buffer to the stream. */
bdd351
 int tio_write(TFILE *fp,const void *buf,size_t count);
bdd351
diff --git a/nss/common.h b/nss/common.h
bdd351
index e8d8e0526499c252f69a558384ddae8504009d26..3f93a4fb4704092dd5b1a41b024d33abf59cba60 100644
bdd351
--- a/nss/common.h
bdd351
+++ b/nss/common.h
bdd351
@@ -2,7 +2,7 @@
bdd351
    common.h - common functions for NSS lookups
bdd351
 
bdd351
    Copyright (C) 2006 West Consulting
bdd351
-   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Arthur de Jong
bdd351
+   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong
bdd351
 
bdd351
    This library is free software; you can redistribute it and/or
bdd351
    modify it under the terms of the GNU Lesser General Public
bdd351
@@ -35,6 +35,10 @@
bdd351
 #include "solnss.h"
bdd351
 #endif /* NSS_FLAVOUR_SOLARIS */
bdd351
 
bdd351
+/* skip timeout determines the maximum time to wait when closing the
bdd351
+   connection and reading whatever data that is available */
bdd351
+#define SKIP_TIMEOUT 500
bdd351
+
bdd351
 /* These are macros for handling read and write problems, they are
bdd351
    NSS specific due to the return code so are defined here. They
bdd351
    genrally close the open file, set an error code and return with
bdd351
@@ -127,7 +131,7 @@
bdd351
   /* close socket and we're done */ \
bdd351
   if ((retv==NSS_STATUS_SUCCESS)||(retv==NSS_STATUS_TRYAGAIN)) \
bdd351
   { \
bdd351
-    (void)tio_skipall(fp); \
bdd351
+    (void)tio_skipall(fp,SKIP_TIMEOUT); \
bdd351
     (void)tio_close(fp); \
bdd351
   } \
bdd351
   return retv;
bdd351
@@ -203,7 +207,7 @@
bdd351
   NSS_AVAILCHECK; \
bdd351
   if (fp!=NULL) \
bdd351
   { \
bdd351
-    (void)tio_skipall(fp); \
bdd351
+    (void)tio_skipall(fp,SKIP_TIMEOUT); \
bdd351
     (void)tio_close(fp); \
bdd351
     fp=NULL; \
bdd351
   } \
bdd351
-- 
bdd351
1.8.3.1
bdd351