diff options
author | Daniel Stenberg <daniel@haxx.se> | 2014-05-20 10:32:23 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2014-05-22 00:34:10 +0200 |
commit | df13f8e8c2199b572f19d295e5c59e7502204b3a (patch) | |
tree | b664dc79f3de9d810f13dd01decbd0b03fcb06b5 /lib/connect.c | |
parent | 491767418bd3e69867d48c2f9b4ea58f7112a879 (diff) |
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.
Diffstat (limited to 'lib/connect.c')
-rw-r--r-- | lib/connect.c | 17 |
1 files changed, 17 insertions, 0 deletions
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 |