Re: 8.14.1: Test 1542 racy?
Stefan Eissing via curl-library <[email protected]>
| Newsgroups | gmane.comp.web.curl.library |
|---|---|
| Message-ID | <[email protected]> |
Not reproducible on macOS. If you apply the attached patch on a debug build, we should learn more. The log in tests/log/stderr1542 should then show when connections are reused with that life times and when they are closed instead. The close that is missing in your failed runs would be missing the line: == Info: Too old connection (20xx ms since creation), disconnect it - Stefan > Am 08.06.2025 um 21:11 schrieb Christian Weisgerber via curl-library <[email protected]>: > > Dan Fandrich: > >>> Seems like some kind of race condition? >> >> Could be. Try running just that test but with the --repeat option to run >> it multiple times in a row, or with that and -j to run multiple copies in >> parallel, and I'm guessing it will fail at some point even on its own. > > Indeed, when I run it with --repeat, the first run succeeds and the > second one fails. Every time. I assume this is a problem in the > test itself rather than in curl? > > $ make test TFLAGS="--repeat=10 1542" > [...] > test 1542...[connection reuse with CURLOPT_MAXLIFETIME_CONN] > --p---oe--- OK (1 out of 10 , remaining: 00:27, took 3.061s, duration: 00:03) > test 1542...[connection reuse with CURLOPT_MAXLIFETIME_CONN] > > 1542: output (log/stderr1542) FAILED: > --- log/check-expected Sun Jun 8 21:09:11 2025 > +++ log/check-generated Sun Jun 8 21:09:11 2025 > @@ -1,5 +1,4 @@ > == Info: Connection #0 to host 127.0.0.1 left intact[CR][LF] > == Info: Connection #0 to host 127.0.0.1 left intact[CR][LF] > == Info: Connection #0 to host 127.0.0.1 left intact[CR][LF] > -== Info: shutting down connection #0[CR][LF] > -== Info: Connection #1 to host 127.0.0.1 left intact[CR][LF] > +== Info: Connection #0 to host 127.0.0.1 left intact[CR][LF] > > - abort tests > [...] > > -- > Christian "naddy" Weisgerber [email protected] > -- > Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library > Etiquette: https://curl.se/mail/etiquette.html -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.html
maxlifetime.diff
(application/octet-stream, 1.8 KB)
diff --git a/lib/url.c b/lib/url.c
index 10e37ec67f..ed06dfd9ea 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -678,28 +678,30 @@ static bool conn_maxage(struct Curl_easy *data,
struct connectdata *conn,
struct curltime now)
{
- timediff_t idletime, lifetime;
+ if(data->set.maxage_conn) {
+ timediff_t idletime = curlx_timediff(now, conn->lastused);
- idletime = curlx_timediff(now, conn->lastused);
- idletime /= 1000; /* integer seconds is fine */
-
- if(idletime > data->set.maxage_conn) {
- infof(data, "Too old connection (%" FMT_TIMEDIFF_T
- " seconds idle), disconnect it", idletime);
- return TRUE;
+ if((idletime / 1000) > data->set.maxage_conn) {
+ infof(data, "Too old connection (%" FMT_TIMEDIFF_T
+ " ms idle), disconnect it", idletime);
+ return TRUE;
+ }
+ DEBUGF(infof(data, "connection has been idle for %" FMT_TIMEDIFF_T
+ " ms (max idle %ld sec)", idletime, data->set.maxage_conn));
}
- lifetime = curlx_timediff(now, conn->created);
- lifetime /= 1000; /* integer seconds is fine */
-
- if(data->set.maxlifetime_conn && lifetime > data->set.maxlifetime_conn) {
- infof(data,
- "Too old connection (%" FMT_TIMEDIFF_T
- " seconds since creation), disconnect it", lifetime);
- return TRUE;
+ if(data->set.maxlifetime_conn) {
+ timediff_t lifetime = curlx_timediff(now, conn->created);
+ if((lifetime / 1000) > data->set.maxlifetime_conn) {
+ infof(data,
+ "Too old connection (%" FMT_TIMEDIFF_T
+ " ms since creation), disconnect it", lifetime);
+ return TRUE;
+ }
+ DEBUGF(infof(data, "connection age is %" FMT_TIMEDIFF_T
+ " ms (max %ld sec)", lifetime, data->set.maxlifetime_conn));
}
-
return FALSE;
}