Skip to content

Commit df67269

Browse files
icingbagder
authored andcommitted
shutdowns: split shutdown handling from connection pool
Further testing with timeouts in event based processing revealed that our current shutdown handling in the connection pool was not clear enough. Graceful shutdowns can only happen inside a multi handle and it was confusing to track in the code which situation actually applies. It seems better to split the shutdown handling off and have that code always be part of a multi handle. Add `cshutdn.[ch]` with its own struct to maintain connections being shut down. A `cshutdn` always belongs to a multi handle and uses that for socket/timeout monitoring. The `cpool`, which can be part of a multi or share, either passes connections to a `cshutdn` or terminates them with a one-time, best effort. Add an `admin` easy handle to each multi and share. This is used to perform all maintenance operations where no "real" easy handle is available. This solves the problem that the multi admin handle requires some additional initialisation (e.g. timeout list). The share needs its admin handle as it is often cleaned up when no other transfer or multi handle exists any more. But we need a `data` in almost every call. Fix file:// handling of errors when adding a new connection to the pool. Changes in `curl` itself: - for parallel transfers, do not set a connection pool in the share, rely on the multi's connection pool instead. While not a requirement for the new `cshutdn` to work, this is a) helpful in testing to trigger graceful shutdowns b) a broader code coverage of libcurl via the curl tool - on test_event with uv, cleanup the multi handle before returning from parallel_event(). The uv struct is on the stack, cleanup of the multi later will crash when it tries to register sockets. This is a "eat your own dogfood" related fix. Closes curl#16508
1 parent 3afa47b commit df67269

23 files changed

+1027
-838
lines changed

lib/Makefile.inc

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ LIB_CFILES = \
123123
cf-socket.c \
124124
cfilters.c \
125125
conncache.c \
126+
cshutdn.c \
126127
connect.c \
127128
content_encoding.c \
128129
cookie.c \
@@ -260,6 +261,7 @@ LIB_HFILES = \
260261
cf-socket.h \
261262
cfilters.h \
262263
conncache.h \
264+
cshutdn.h \
263265
connect.h \
264266
content_encoding.h \
265267
cookie.h \

lib/cfilters.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ CURLcode Curl_conn_shutdown(struct Curl_easy *data, int sockindex, bool *done)
202202
if(!Curl_shutdown_started(data, sockindex)) {
203203
CURL_TRC_M(data, "shutdown start on%s connection",
204204
sockindex ? " secondary" : "");
205-
Curl_shutdown_start(data, sockindex, &now);
205+
Curl_shutdown_start(data, sockindex, 0, &now);
206206
}
207207
else {
208208
timeout_ms = Curl_shutdown_timeleft(data->conn, sockindex, &now);

0 commit comments

Comments
 (0)