aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-12-11 20:13:29 +0100
committerDaniel Stenberg <daniel@haxx.se>2012-12-24 23:51:02 +0100
commit1649e680f62450a29589c23c64a67267e9e439f2 (patch)
tree561e8514e8b7d3b9ea464c4b2c3a57bce721856d /lib
parent2897ce7dc2e1b7e8c94e8fc79f6199c33efe7547 (diff)
Curl_conncache_foreach: allow callback to break loop
... and have it take a proper 'struct connectdata *' as first argument
Diffstat (limited to 'lib')
-rw-r--r--lib/conncache.c10
-rw-r--r--lib/conncache.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/conncache.c b/lib/conncache.c
index 4bca7ba51..a3a90f879 100644
--- a/lib/conncache.c
+++ b/lib/conncache.c
@@ -180,10 +180,13 @@ void Curl_conncache_remove_conn(struct conncache *connc,
/* This function iterates the entire connection cache and calls the
function func() with the connection pointer as the first argument
- and the supplied 'param' argument as the other */
+ and the supplied 'param' argument as the other,
+
+ Return 0 from func() to continue the loop, return 1 to abort it.
+ */
void Curl_conncache_foreach(struct conncache *connc,
void *param,
- void (*func)(void *conn, void *param))
+ int (*func)(struct connectdata *conn, void *param))
{
struct curl_hash_iterator iter;
struct curl_llist_element *curr;
@@ -208,7 +211,8 @@ void Curl_conncache_foreach(struct conncache *connc,
conn = curr->ptr;
curr = curr->next;
- func(conn, param);
+ if(1 == func(conn, param))
+ return;
}
he = Curl_hash_next_element(&iter);
diff --git a/lib/conncache.h b/lib/conncache.h
index 7b7baae2c..03b129d4e 100644
--- a/lib/conncache.h
+++ b/lib/conncache.h
@@ -48,7 +48,8 @@ void Curl_conncache_remove_conn(struct conncache *connc,
void Curl_conncache_foreach(struct conncache *connc,
void *param,
- void (*func)(void *, void *));
+ int (*func)(struct connectdata *conn,
+ void *param));
struct connectdata *
Curl_conncache_find_first_connection(struct conncache *connc);