aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-03-13 07:54:18 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-03-13 07:54:18 +0000
commit87b0b7cab9924848aa7be2fc154379b39356132b (patch)
tree1a73b890ed13a31adec77e5db1e9f6c37b14b6ee
parent70d0d9d4daa502affca0c9ddcd1522330d3d7b5f (diff)
initial close policy support
-rw-r--r--lib/url.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/url.c b/lib/url.c
index 3194cbe20..fc9b33e15 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -941,6 +941,9 @@ ConnectionKillOne(struct UrlData *data)
int connindex=-1;
int score;
CURLcode result;
+ struct timeval now;
+
+ now = Curl_tvnow();
for(i=0; i< data->numconnects; i++) {
conn = data->connects[i];
@@ -952,8 +955,20 @@ ConnectionKillOne(struct UrlData *data)
* By using the set policy, we score each connection.
*/
switch(data->closepolicy) {
+ case CURLCLOSEPOLICY_LEAST_RECENTLY_USED:
default:
- score = 1; /* not implemented yet */
+ /*
+ * Set higher score for the age passed since the connection
+ * was used.
+ */
+ score = Curl_tvlong(now) - Curl_tvlong(conn->now);
+ break;
+ case CURLCLOSEPOLICY_OLDEST:
+ /*
+ * Set higher score for the age passed since the connection
+ * was created.
+ */
+ score = Curl_tvlong(now) - Curl_tvlong(conn->created);
break;
}
@@ -1269,11 +1284,13 @@ static CURLcode Connect(struct UrlData *data,
conn->connectindex = -1; /* no index */
conn->bits.httpproxy = data->bits.httpproxy; /* proxy-or-not status */
- /* Default protocol-indepent behaveiour doesn't support persistant
+ /* Default protocol-independent behavior doesn't support persistant
connections, so we set this to force-close. Protocols that support
this need to set this to FALSE in their "curl_do" functions. */
conn->bits.close = TRUE;
+ /* Store creation time to help future close decision making */
+ conn->created = Curl_tvnow();
/***********************************************************
* We need to allocate memory to store the path in. We get the size of the