From 85c4904bc526103e5702c716ee80d03937083168 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Thu, 1 May 2008 01:45:00 +0000 Subject: [PATCH] allow connections to be removed from an rpc pool svn:r753 --- ChangeLog | 1 + evrpc.c | 10 +++++++++- evrpc.h | 26 +++++++++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a5fa85b..b6356f0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -80,6 +80,7 @@ Changes in current version: o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy. o Remove the never-exported, never-used evhttp_hostportfile function. o Support input/output filters for bufferevents; somewhat similar to libio's model. This will allow us to implement SSL, compression, etc, transparently to users of bufferevents such as the http layer. + o allow connections to be removed from an rpc pool Changes in 1.4.0: o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. diff --git a/evrpc.c b/evrpc.c index 6d9e81dd..1d8bb604 100644 --- a/evrpc.c +++ b/evrpc.c @@ -541,7 +541,8 @@ evrpc_pool_free(struct evrpc_pool *pool) void evrpc_pool_add_connection(struct evrpc_pool *pool, - struct evhttp_connection *connection) { + struct evhttp_connection *connection) +{ assert(connection->http_server == NULL); TAILQ_INSERT_TAIL(&pool->connections, connection, next); @@ -571,6 +572,13 @@ evrpc_pool_add_connection(struct evrpc_pool *pool, } } +void +evrpc_pool_remove_connection(struct evrpc_pool *pool, + struct evhttp_connection *connection) +{ + TAILQ_REMOVE(&pool->connections, connection, next); +} + void evrpc_pool_set_timeout(struct evrpc_pool *pool, int timeout_in_secs) { diff --git a/evrpc.h b/evrpc.h index 26359187..f7f17134 100644 --- a/evrpc.h +++ b/evrpc.h @@ -430,12 +430,28 @@ struct evrpc_pool *evrpc_pool_new(struct event_base *base); * @see evrpc_pool_new() */ void evrpc_pool_free(struct evrpc_pool *pool); -/* - * adds a connection over which rpc can be dispatched. the connection - * object must have been newly created. + +/** + * Adds a connection over which rpc can be dispatched to the pool. + * + * The connection object must have been newly created. + * + * @param pool the pool to which to add the connection + * @param evcon the connection to add to the pool. + */ +void evrpc_pool_add_connection(struct evrpc_pool *pool, + struct evhttp_connection *evcon); + +/** + * Removes a connection from the pool. + * + * The connection object must have been newly created. + * + * @param pool the pool from which to remove the connection + * @param evcon the connection to remove from the pool. */ -void evrpc_pool_add_connection(struct evrpc_pool *, - struct evhttp_connection *); +void evrpc_pool_remove_connection(struct evrpc_pool *pool, + struct evhttp_connection *evcon); /** * Sets the timeout in secs after which a request has to complete. The -- 2.40.0