curl_global_init: accept the CURL_GLOBAL_ACK_EINTR flag
authorZdenek Pavlas <zpavlas@redhat.com>
Mon, 11 Mar 2013 13:57:07 +0000 (14:57 +0100)
committerKamil Dudka <kdudka@redhat.com>
Tue, 12 Mar 2013 09:58:20 +0000 (10:58 +0100)
The flag can be used in pycurl-based applications where using the multi
interface would not be acceptable because of the performance lost caused
by implementing the select() loop in python.

Bug: http://curl.haxx.se/bug/view.cgi?id=1168
Downstream Bug: https://bugzilla.redhat.com/919127

RELEASE-NOTES
docs/libcurl/curl_global_init.3
docs/libcurl/symbols-in-versions
include/curl/curl.h
lib/easy.c
lib/select.c
lib/select.h

index b41a566..d8f4ce3 100644 (file)
@@ -24,6 +24,7 @@ This release includes the following changes:
  o darwinssl: Make certificate errors less techy
  o imap/pop3/smtp: Added support for the STARTTLS capability
  o checksrc: ban use of sprintf, vsprintf, strcat, strncat and gets
+ o curl_global_init() now accepts the CURL_GLOBAL_ACK_EINTR flag [10]
 
 This release includes the following bugfixes:
 
@@ -81,3 +82,4 @@ References to bug reports and discussions on issues:
  [7] = http://curl.haxx.se/bug/view.cgi?id=1190
  [8] = http://curl.haxx.se/bug/view.cgi?id=1193
  [9] = http://curl.haxx.se/bug/view.cgi?id=1194
+ [10] = http://curl.haxx.se/bug/view.cgi?id=1168
index d91e1bd..6a08383 100644 (file)
@@ -70,6 +70,10 @@ Initialise nothing extra. This sets no bit.
 .B CURL_GLOBAL_DEFAULT
 A sensible default. It will init both SSL and Win32. Right now, this equals
 the functionality of the \fBCURL_GLOBAL_ALL\fP mask.
+.TP
+.B CURL_GLOBAL_ACK_EINTR
+When this flag is set, curl will acknowledge EINTR condition when connecting
+or when waiting for data.  Otherwise, curl waits until full timeout elapses.
 .SH RETURN VALUE
 If this function returns non-zero, something went wrong and you cannot use the
 other curl functions.
index 1de1ace..37b5e27 100644 (file)
@@ -614,6 +614,7 @@ CURL_GLOBAL_DEFAULT             7.8
 CURL_GLOBAL_NOTHING             7.8
 CURL_GLOBAL_SSL                 7.8
 CURL_GLOBAL_WIN32               7.8.1
+CURL_GLOBAL_ACK_EINTR           7.30.0
 CURL_HTTP_VERSION_1_0           7.9.1
 CURL_HTTP_VERSION_1_1           7.9.1
 CURL_HTTP_VERSION_NONE          7.9.1
index 50f4043..0b2b7ea 100644 (file)
@@ -2015,6 +2015,7 @@ typedef enum {
 #define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
 #define CURL_GLOBAL_NOTHING 0
 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
+#define CURL_GLOBAL_ACK_EINTR (1<<2)
 
 
 /*****************************************************************************
index 2e747bb..2739598 100644 (file)
@@ -262,6 +262,8 @@ CURLcode curl_global_init(long flags)
   }
 #endif
 
+  Curl_ack_eintr = flags & CURL_GLOBAL_ACK_EINTR;
+
   init_flags  = flags;
 
   /* Preset pseudo-random number sequence. */
index d13e122..db7fb6d 100644 (file)
 
 #define elapsed_ms  (int)curlx_tvdiff(curlx_tvnow(), initial_tv)
 
-#ifdef CURL_ACKNOWLEDGE_EINTR
-#define error_not_EINTR (1)
-#else
-#define error_not_EINTR (error != EINTR)
-#endif
+int Curl_ack_eintr = 0;
+#define error_not_EINTR (Curl_ack_eintr || error != EINTR)
 
 /*
  * Internal function used for waiting a specific amount of ms
  * Timeout resolution, accuracy, as well as maximum supported
  * value is system dependent, neither factor is a citical issue
  * for the intended use of this function in the library.
- * On non-DOS and non-Winsock platforms, when compiled with
- * CURL_ACKNOWLEDGE_EINTR defined, EINTR condition is honored
- * and function might exit early without awaiting full timeout,
- * otherwise EINTR will be ignored and full timeout will elapse.
  *
  * Return values:
  *   -1 = system call error, invalid timeout value, or interrupted
@@ -133,9 +126,6 @@ int Curl_wait_ms(int timeout_ms)
  * A negative timeout value makes this function wait indefinitely,
  * unles no valid file descriptor is given, when this happens the
  * negative timeout is ignored and the function times out immediately.
- * When compiled with CURL_ACKNOWLEDGE_EINTR defined, EINTR condition
- * is honored and function might exit early without awaiting timeout,
- * otherwise EINTR will be ignored.
  *
  * Return values:
  *   -1 = system call error or fd >= FD_SETSIZE
@@ -351,9 +341,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
  * A negative timeout value makes this function wait indefinitely,
  * unles no valid file descriptor is given, when this happens the
  * negative timeout is ignored and the function times out immediately.
- * When compiled with CURL_ACKNOWLEDGE_EINTR defined, EINTR condition
- * is honored and function might exit early without awaiting timeout,
- * otherwise EINTR will be ignored.
  *
  * Return values:
  *   -1 = system call error or fd >= FD_SETSIZE
index 00789bb..c00afe1 100644 (file)
@@ -81,6 +81,12 @@ int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
 
 int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
 
+/* On non-DOS and non-Winsock platforms, when Curl_ack_eintr is set,
+ * EINTR condition is honored and function might exit early without
+ * awaiting full timeout.  Otherwise EINTR will be ignored and full
+ * timeout will elapse. */
+extern int Curl_ack_eintr;
+
 int Curl_wait_ms(int timeout_ms);
 
 #ifdef TPF