|
|
3a27f0 |
From 37a515d9933a3160a8a868d5a697a42b28f6d792 Mon Sep 17 00:00:00 2001
|
|
|
3a27f0 |
From: Zdenek Pavlas <zpavlas@redhat.com>
|
|
|
3a27f0 |
Date: Mon, 11 Mar 2013 14:57:07 +0100
|
|
|
3a27f0 |
Subject: [PATCH 2/2] curl_global_init: accept the CURL_GLOBAL_ACK_EINTR flag
|
|
|
3a27f0 |
|
|
|
3a27f0 |
The flag can be used in pycurl-based applications where using the multi
|
|
|
3a27f0 |
interface would not be acceptable because of the performance lost caused
|
|
|
3a27f0 |
by implementing the select() loop in python.
|
|
|
3a27f0 |
|
|
|
3a27f0 |
Bug: http://curl.haxx.se/bug/view.cgi?id=1168
|
|
|
3a27f0 |
Downstream Bug: https://bugzilla.redhat.com/919127
|
|
|
3a27f0 |
|
|
|
3a27f0 |
[upstream commit 57ccdfa8d2bb6275388223f4676cd623ebd01697]
|
|
|
3a27f0 |
---
|
|
|
3a27f0 |
docs/libcurl/curl_global_init.3 | 4 ++++
|
|
|
3a27f0 |
docs/libcurl/symbols-in-versions | 1 +
|
|
|
3a27f0 |
include/curl/curl.h | 1 +
|
|
|
3a27f0 |
lib/easy.c | 2 ++
|
|
|
3a27f0 |
lib/select.c | 17 ++---------------
|
|
|
3a27f0 |
lib/select.h | 6 ++++++
|
|
|
3a27f0 |
6 files changed, 16 insertions(+), 15 deletions(-)
|
|
|
3a27f0 |
|
|
|
3a27f0 |
diff --git a/docs/libcurl/curl_global_init.3 b/docs/libcurl/curl_global_init.3
|
|
|
3a27f0 |
index d91e1bd..6a08383 100644
|
|
|
3a27f0 |
--- a/docs/libcurl/curl_global_init.3
|
|
|
3a27f0 |
+++ b/docs/libcurl/curl_global_init.3
|
|
|
3a27f0 |
@@ -70,6 +70,10 @@ Initialise nothing extra. This sets no bit.
|
|
|
3a27f0 |
.B CURL_GLOBAL_DEFAULT
|
|
|
3a27f0 |
A sensible default. It will init both SSL and Win32. Right now, this equals
|
|
|
3a27f0 |
the functionality of the \fBCURL_GLOBAL_ALL\fP mask.
|
|
|
3a27f0 |
+.TP
|
|
|
3a27f0 |
+.B CURL_GLOBAL_ACK_EINTR
|
|
|
3a27f0 |
+When this flag is set, curl will acknowledge EINTR condition when connecting
|
|
|
3a27f0 |
+or when waiting for data. Otherwise, curl waits until full timeout elapses.
|
|
|
3a27f0 |
.SH RETURN VALUE
|
|
|
3a27f0 |
If this function returns non-zero, something went wrong and you cannot use the
|
|
|
3a27f0 |
other curl functions.
|
|
|
3a27f0 |
diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions
|
|
|
3a27f0 |
index 1de1ace..37b5e27 100644
|
|
|
3a27f0 |
--- a/docs/libcurl/symbols-in-versions
|
|
|
3a27f0 |
+++ b/docs/libcurl/symbols-in-versions
|
|
|
3a27f0 |
@@ -614,6 +614,7 @@ CURL_GLOBAL_DEFAULT 7.8
|
|
|
3a27f0 |
CURL_GLOBAL_NOTHING 7.8
|
|
|
3a27f0 |
CURL_GLOBAL_SSL 7.8
|
|
|
3a27f0 |
CURL_GLOBAL_WIN32 7.8.1
|
|
|
3a27f0 |
+CURL_GLOBAL_ACK_EINTR 7.30.0
|
|
|
3a27f0 |
CURL_HTTP_VERSION_1_0 7.9.1
|
|
|
3a27f0 |
CURL_HTTP_VERSION_1_1 7.9.1
|
|
|
3a27f0 |
CURL_HTTP_VERSION_NONE 7.9.1
|
|
|
3a27f0 |
diff --git a/include/curl/curl.h b/include/curl/curl.h
|
|
|
3a27f0 |
index 5b39a24..80e4cf5 100644
|
|
|
3a27f0 |
--- a/include/curl/curl.h
|
|
|
3a27f0 |
+++ b/include/curl/curl.h
|
|
|
3a27f0 |
@@ -2023,6 +2023,7 @@ typedef enum {
|
|
|
3a27f0 |
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
|
|
|
3a27f0 |
#define CURL_GLOBAL_NOTHING 0
|
|
|
3a27f0 |
#define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL
|
|
|
3a27f0 |
+#define CURL_GLOBAL_ACK_EINTR (1<<2)
|
|
|
3a27f0 |
|
|
|
3a27f0 |
|
|
|
3a27f0 |
/*****************************************************************************
|
|
|
3a27f0 |
diff --git a/lib/easy.c b/lib/easy.c
|
|
|
3a27f0 |
index 2e747bb..2739598 100644
|
|
|
3a27f0 |
--- a/lib/easy.c
|
|
|
3a27f0 |
+++ b/lib/easy.c
|
|
|
3a27f0 |
@@ -262,6 +262,8 @@ CURLcode curl_global_init(long flags)
|
|
|
3a27f0 |
}
|
|
|
3a27f0 |
#endif
|
|
|
3a27f0 |
|
|
|
3a27f0 |
+ Curl_ack_eintr = flags & CURL_GLOBAL_ACK_EINTR;
|
|
|
3a27f0 |
+
|
|
|
3a27f0 |
init_flags = flags;
|
|
|
3a27f0 |
|
|
|
3a27f0 |
/* Preset pseudo-random number sequence. */
|
|
|
3a27f0 |
diff --git a/lib/select.c b/lib/select.c
|
|
|
3a27f0 |
index d13e122..db7fb6d 100644
|
|
|
3a27f0 |
--- a/lib/select.c
|
|
|
3a27f0 |
+++ b/lib/select.c
|
|
|
3a27f0 |
@@ -50,11 +50,8 @@
|
|
|
3a27f0 |
|
|
|
3a27f0 |
#define elapsed_ms (int)curlx_tvdiff(curlx_tvnow(), initial_tv)
|
|
|
3a27f0 |
|
|
|
3a27f0 |
-#ifdef CURL_ACKNOWLEDGE_EINTR
|
|
|
3a27f0 |
-#define error_not_EINTR (1)
|
|
|
3a27f0 |
-#else
|
|
|
3a27f0 |
-#define error_not_EINTR (error != EINTR)
|
|
|
3a27f0 |
-#endif
|
|
|
3a27f0 |
+int Curl_ack_eintr = 0;
|
|
|
3a27f0 |
+#define error_not_EINTR (Curl_ack_eintr || error != EINTR)
|
|
|
3a27f0 |
|
|
|
3a27f0 |
/*
|
|
|
3a27f0 |
* Internal function used for waiting a specific amount of ms
|
|
|
3a27f0 |
@@ -67,10 +64,6 @@
|
|
|
3a27f0 |
* Timeout resolution, accuracy, as well as maximum supported
|
|
|
3a27f0 |
* value is system dependent, neither factor is a citical issue
|
|
|
3a27f0 |
* for the intended use of this function in the library.
|
|
|
3a27f0 |
- * On non-DOS and non-Winsock platforms, when compiled with
|
|
|
3a27f0 |
- * CURL_ACKNOWLEDGE_EINTR defined, EINTR condition is honored
|
|
|
3a27f0 |
- * and function might exit early without awaiting full timeout,
|
|
|
3a27f0 |
- * otherwise EINTR will be ignored and full timeout will elapse.
|
|
|
3a27f0 |
*
|
|
|
3a27f0 |
* Return values:
|
|
|
3a27f0 |
* -1 = system call error, invalid timeout value, or interrupted
|
|
|
3a27f0 |
@@ -133,9 +126,6 @@ int Curl_wait_ms(int timeout_ms)
|
|
|
3a27f0 |
* A negative timeout value makes this function wait indefinitely,
|
|
|
3a27f0 |
* unles no valid file descriptor is given, when this happens the
|
|
|
3a27f0 |
* negative timeout is ignored and the function times out immediately.
|
|
|
3a27f0 |
- * When compiled with CURL_ACKNOWLEDGE_EINTR defined, EINTR condition
|
|
|
3a27f0 |
- * is honored and function might exit early without awaiting timeout,
|
|
|
3a27f0 |
- * otherwise EINTR will be ignored.
|
|
|
3a27f0 |
*
|
|
|
3a27f0 |
* Return values:
|
|
|
3a27f0 |
* -1 = system call error or fd >= FD_SETSIZE
|
|
|
3a27f0 |
@@ -351,9 +341,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
|
|
3a27f0 |
* A negative timeout value makes this function wait indefinitely,
|
|
|
3a27f0 |
* unles no valid file descriptor is given, when this happens the
|
|
|
3a27f0 |
* negative timeout is ignored and the function times out immediately.
|
|
|
3a27f0 |
- * When compiled with CURL_ACKNOWLEDGE_EINTR defined, EINTR condition
|
|
|
3a27f0 |
- * is honored and function might exit early without awaiting timeout,
|
|
|
3a27f0 |
- * otherwise EINTR will be ignored.
|
|
|
3a27f0 |
*
|
|
|
3a27f0 |
* Return values:
|
|
|
3a27f0 |
* -1 = system call error or fd >= FD_SETSIZE
|
|
|
3a27f0 |
diff --git a/lib/select.h b/lib/select.h
|
|
|
3a27f0 |
index 00789bb..c00afe1 100644
|
|
|
3a27f0 |
--- a/lib/select.h
|
|
|
3a27f0 |
+++ b/lib/select.h
|
|
|
3a27f0 |
@@ -81,6 +81,12 @@ int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
|
|
|
3a27f0 |
|
|
|
3a27f0 |
int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
|
|
|
3a27f0 |
|
|
|
3a27f0 |
+/* On non-DOS and non-Winsock platforms, when Curl_ack_eintr is set,
|
|
|
3a27f0 |
+ * EINTR condition is honored and function might exit early without
|
|
|
3a27f0 |
+ * awaiting full timeout. Otherwise EINTR will be ignored and full
|
|
|
3a27f0 |
+ * timeout will elapse. */
|
|
|
3a27f0 |
+extern int Curl_ack_eintr;
|
|
|
3a27f0 |
+
|
|
|
3a27f0 |
int Curl_wait_ms(int timeout_ms);
|
|
|
3a27f0 |
|
|
|
3a27f0 |
#ifdef TPF
|
|
|
3a27f0 |
--
|
|
|
3a27f0 |
1.7.1
|
|
|
3a27f0 |
|