gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_2-12-gb8c9e


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_2-12-gb8c9e71
Date: Tue, 12 Apr 2011 09:59:11 +0000

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 "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=b8c9e719a4d034e6e27a1faa9512377486178027

The branch, gnutls_2_12_x has been updated
       via  b8c9e719a4d034e6e27a1faa9512377486178027 (commit)
       via  bb7c9c517f81d263d0d9d8281924e70f77143a10 (commit)
      from  a8fba8e8d68134421bbc5027318d06591588c114 (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 -----------------------------------------------------------------
commit b8c9e719a4d034e6e27a1faa9512377486178027
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Apr 12 11:58:57 2011 +0200

    documented fix.

commit bb7c9c517f81d263d0d9d8281924e70f77143a10
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Apr 12 11:57:02 2011 +0200

    Do not rely on lowat being set.

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

Summary of changes:
 NEWS      |    4 +++
 src/cli.c |   65 ++++++++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/NEWS b/NEWS
index 0fbe56c..936e2f7 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,10 @@ See the end for copying conditions.
 * libgnutls: gnutls_transport_set_global_errno() was deprecated.
 Use your system's errno fascility or gnutls_transport_set_errno().
 
+* gnutls-cli: Correction with usage of select to check for
+pending data in gnutls sessions. It now uses gnutls_record_check_pending().
+Reported by Herbert J. Skuhra.
+
 * tests: More fixes and updates for win32. Patches by LRN.
 
 ** API and ABI modifications:
diff --git a/src/cli.c b/src/cli.c
index 3ff25d5..d886a86 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -674,19 +674,58 @@ tls_log_func (int level, const char *str)
   fprintf (stderr, "|<%d>| %s", level, str);
 }
 
+#define IN_KEYBOARD 1
+#define IN_NET 2
+#define IN_NONE 0
+/* returns IN_KEYBOARD for keyboard input and IN_NET for network input
+ */
+static int check_net_or_keyboard_input(socket_st* hd)
+{
+  int maxfd;
+  fd_set rset;
+  int err;
+  struct timeval tv;
+
+  do
+    {
+      FD_ZERO (&rset);
+      FD_SET (fileno (stdin), &rset);
+      FD_SET (hd->fd, &rset);
+
+      maxfd = MAX (fileno (stdin), hd->fd);
+      tv.tv_sec = 0;
+      tv.tv_usec = 500 * 1000;
+
+      if (hd->secure == 1)
+        if (gnutls_record_check_pending(hd->session))
+          return IN_NET;
+
+      err = select (maxfd + 1, &rset, NULL, NULL, &tv);
+      if (err < 0)
+        continue;
+
+      if (FD_ISSET (hd->fd, &rset))
+        return IN_NET;
+
+
+      if (FD_ISSET (fileno (stdin), &rset))
+        return IN_KEYBOARD;
+    }
+  while(err == 0);
+  
+  return IN_NONE;
+}
+
 int
 main (int argc, char **argv)
 {
-  int err, ret;
-  int ii, i;
+  int ret;
+  int ii, i, inp;
   char buffer[MAX_BUF + 1];
   char *session_data = NULL;
   char *session_id = NULL;
   size_t session_data_size;
   size_t session_id_size = 0;
-  fd_set rset;
-  int maxfd;
-  struct timeval tv;
   int user_term = 0, retval = 0;
   socket_st hd;
   ssize_t bytes;
@@ -845,19 +884,9 @@ after_handshake:
             }
         }
 
-      FD_ZERO (&rset);
-      FD_SET (fileno (stdin), &rset);
-      FD_SET (hd.fd, &rset);
+      inp = check_net_or_keyboard_input(&hd);
 
-      maxfd = MAX (fileno (stdin), hd.fd);
-      tv.tv_sec = 3;
-      tv.tv_usec = 0;
-
-      err = select (maxfd + 1, &rset, NULL, NULL, &tv);
-      if (err < 0)
-        continue;
-
-      if (FD_ISSET (hd.fd, &rset))
+      if (inp == IN_NET)
         {
           memset (buffer, 0, MAX_BUF + 1);
           ret = socket_recv (&hd, buffer, MAX_BUF);
@@ -889,7 +918,7 @@ after_handshake:
             break;
         }
 
-      if (FD_ISSET (fileno (stdin), &rset))
+      if (inp == IN_KEYBOARD)
         {
           if ((bytes = read (fileno (stdin), buffer, MAX_BUF - 1)) <= 0)
             {


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]