]> granicus.if.org Git - curl/commitdiff
Brendan Jurd provided a fix that now prevents libcurl from getting a SIGPIPE
authorDaniel Stenberg <daniel@haxx.se>
Sat, 16 Dec 2006 21:33:51 +0000 (21:33 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 16 Dec 2006 21:33:51 +0000 (21:33 +0000)
during certain conditions when GnuTLS is used.

CHANGES
RELEASE-NOTES
lib/gtls.c

diff --git a/CHANGES b/CHANGES
index d807af2cae760eae6ac79e76fc122e935f7a68ac..acd7ed76373b907426d7152ba6b5c1fa0c820b18 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@
 
                                   Changelog
 
+Daniel (16 December 2006)
+- Brendan Jurd provided a fix that now prevents libcurl from getting a SIGPIPE
+  during certain conditions when GnuTLS is used.
+
 Daniel (11 December 2006)
 - Alexey Simak found out that when doing FTP with the multi interface and
   something went wrong like it got a bad response code back from the server,
index f40c2ff3b111589fe784261ec4f61e86ca7d70bc..d1823d4b88efa6777db99933fc2247a2e71bf330 100644 (file)
@@ -35,6 +35,7 @@ This release includes the following bugfixes:
  o rate limiting works better
  o getting FTP response code errors when using the multi-interface caused
    libcurl to leak memory
+ o no more SIGPIPE when GnuTLS is used
 
 Other curl-related news:
 
@@ -53,6 +54,6 @@ advice from friends like these:
  James Housley, Olaf Stueben, Yang Tse, Gisle Vanem, Bradford Bruce,
  Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella, Toon Verwaest,
  Matt Witherspoon, Alexey Simak, Martin Skinner, Sh Diao, Jared Lundell,
- Stefan Krause, Sebastien Willemijns, Alexey Simak
+ Stefan Krause, Sebastien Willemijns, Alexey Simak, Brendan Jurd
 
         Thanks! (and sorry if I forgot to mention someone)
index ee7612028a7246f69f88541274cac1cadd102c79..bbd87161dfcbafebddfa40d9e2cb0fbd803edee6 100644 (file)
@@ -67,6 +67,23 @@ static void tls_log_func(int level, const char *str)
 }
 #endif
 
+/*
+ * Custom push and pull callback functions used by GNU TLS to read and write
+ * to the socket.  These functions are simple wrappers to send() and recv()
+ * (although here using the sread/swrite macros as defined by setup_once.h).
+ * We use custom functions rather than the GNU TLS defaults because it allows
+ * us to get specific about the fourth "flags" argument, and to use arbitrary
+ * private data with gnutls_transport_set_ptr if we wish.
+ */
+static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
+{
+  return swrite(s, buf, len);
+}
+
+static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len)
+{
+  return sread(s, buf, len);
+}
 
 /* Global GnuTLS init, called from Curl_ssl_init() */
 int Curl_gtls_init(void)
@@ -285,6 +302,13 @@ Curl_gtls_connect(struct connectdata *conn,
   gnutls_transport_set_ptr(session,
                            (gnutls_transport_ptr)conn->sock[sockindex]);
 
+  /* register callback functions to send and receive data. */
+  gnutls_transport_set_push_function(session, Curl_gtls_push);
+  gnutls_transport_set_pull_function(session, Curl_gtls_pull);
+
+  /* lowat must be set to zero when using custom push and pull functions. */
+  gnutls_transport_set_lowat(session, 0);
+
   /* This might be a reconnect, so we check for a session ID in the cache
      to speed up things */