From 9f15a2646ae6c666ac16c2d779afc3ee205df069 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 19 Apr 2007 16:07:20 +0000 Subject: [PATCH] Refactor access to global variable channel_list. There were a few places where this was accessed and always in the same way. --- src/http.c | 11 ++++------- src/http_command.c | 8 ++++---- src/logic.c | 18 +++++++++++++----- src/pazpar2.c | 4 ++-- src/pazpar2.h | 6 +++--- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/http.c b/src/http.c index 020e285..f4aa55d 100644 --- a/src/http.c +++ b/src/http.c @@ -1,4 +1,4 @@ -/* $Id: http.c,v 1.27 2007-04-16 09:03:25 adam Exp $ +/* $Id: http.c,v 1.28 2007-04-19 16:07:20 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -608,8 +608,7 @@ static int http_proxy(struct http_request *rq) // We will add EVENT_OUTPUT below p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT); iochan_setdata(p->iochan, p); - p->iochan->next = channel_list; - channel_list = p->iochan; + pazpar2_add_channel(p->iochan); } // Do _not_ modify Host: header, just checking it's existence @@ -977,8 +976,7 @@ static void http_accept(IOCHAN i, int event) ch->iochan = c; iochan_setdata(c, ch); - c->next = channel_list; - channel_list = c; + pazpar2_add_channel(c); } /* Create a http-channel listener, syntax [host:]port */ @@ -1042,8 +1040,7 @@ void http_init(const char *addr) yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen"); c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT); - c->next = channel_list; - channel_list = c; + pazpar2_add_channel(c); } void http_set_proxyaddr(char *host, char *base_url) diff --git a/src/http_command.c b/src/http_command.c index 98d84fd..f44fdf3 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,4 +1,4 @@ -/* $Id: http_command.c,v 1.39 2007-04-19 15:31:23 adam Exp $ +/* $Id: http_command.c,v 1.40 2007-04-19 16:07:20 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ /* - * $Id: http_command.c,v 1.39 2007-04-19 15:31:23 adam Exp $ + * $Id: http_command.c,v 1.40 2007-04-19 16:07:20 adam Exp $ */ #include @@ -82,8 +82,8 @@ struct http_session *http_session_create() r->timeout_iochan = iochan_create(-1, session_timeout, 0); iochan_setdata(r->timeout_iochan, r); iochan_settimeout(r->timeout_iochan, global_parameters.session_timeout); - r->timeout_iochan->next = channel_list; - channel_list = r->timeout_iochan; + + pazpar2_add_channel(r->timeout_iochan); return r; } diff --git a/src/logic.c b/src/logic.c index c581f2d..c8ad513 100644 --- a/src/logic.c +++ b/src/logic.c @@ -1,4 +1,4 @@ -/* $Id: logic.c,v 1.9 2007-04-18 19:45:09 quinn Exp $ +/* $Id: logic.c,v 1.10 2007-04-19 16:07:20 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -74,8 +74,6 @@ static int client_prep_connection(struct client *cl); static void ingest_records(struct client *cl, Z_Records *r); void session_alert_watch(struct session *s, int what); -IOCHAN channel_list = 0; // Master list of connections we're handling events to - static struct connection *connection_freelist = 0; static struct client *client_freelist = 0; @@ -1192,8 +1190,7 @@ static struct connection *connection_create(struct client *cl) new->iochan = iochan_create(cs_fileno(link), handler, 0); iochan_setdata(new->iochan, new); - new->iochan->next = channel_list; - channel_list = new->iochan; + pazpar2_add_channel(new->iochan); return new; } @@ -1755,7 +1752,18 @@ void start_zproxy(void) return; } +// Master list of connections we're handling events to +static IOCHAN channel_list = 0; +void pazpar2_add_channel(IOCHAN chan) +{ + chan->next = channel_list; + channel_list = chan; +} +void pazpar2_event_loop() +{ + event_loop(&channel_list); +} /* * Local variables: diff --git a/src/pazpar2.c b/src/pazpar2.c index 682da9c..7ded17a 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.79 2007-04-16 09:03:25 adam Exp $ +/* $Id: pazpar2.c,v 1.80 2007-04-19 16:07:20 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -99,7 +99,7 @@ int main(int argc, char **argv) global_parameters.odr_in = odr_createmem(ODR_DECODE); global_parameters.odr_out = odr_createmem(ODR_ENCODE); - event_loop(&channel_list); + pazpar2_event_loop(); return 0; } diff --git a/src/pazpar2.h b/src/pazpar2.h index 1f65270..63489e3 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -1,4 +1,4 @@ -/* $Id: pazpar2.h,v 1.25 2007-04-17 21:25:26 quinn Exp $ +/* $Id: pazpar2.h,v 1.26 2007-04-19 16:07:20 adam Exp $ Copyright (c) 2006-2007, Index Data. This file is part of Pazpar2. @@ -267,8 +267,8 @@ void start_proxy(void); void start_zproxy(void); extern struct parameters global_parameters; -extern IOCHAN channel_list; - +void pazpar2_add_channel(IOCHAN c); +void pazpar2_event_loop(void); #endif /* -- 1.7.10.4