From df13f8e8c2199b572f19d295e5c59e7502204b3a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 20 May 2014 10:32:23 +0200 Subject: bits.close: introduce connection close tracking Make all code use connclose() and connkeep() when changing the "close state" for a connection. These two macros take a string argument with an explanation, and debug builds of curl will include that in the debug output. Helps tracking connection re-use/close issues. --- lib/connect.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/connect.c') diff --git a/lib/connect.c b/lib/connect.c index ca6e3466c..de78c33e2 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -1321,3 +1321,20 @@ CURLcode Curl_socket(struct connectdata *conn, return CURLE_OK; } + +#ifdef CURLDEBUG +/* + * Curl_conncontrol() is used to set the conn->bits.close bit on or off. It + * MUST be called with the connclose() or connclose() macros with a stated + * reason. The reason is only shown in debug builds but helps to figure out + * decision paths when connections are or aren't re-used as expected. + */ +void Curl_conncontrol(struct connectdata *conn, bool closeit, + const char *reason) +{ + infof(conn->data, "Marked for [%s]: %s\n", closeit?"closure":"keep alive", + reason); + conn->bits.close = closeit; /* the only place in the source code that should + assign this bit */ +} +#endif -- cgit v1.2.3