From 74f3e867802e2f6b4e1f803b2e98c1e886a515bf Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 7 Feb 2013 14:21:05 +0100 Subject: [PATCH] Change session locking further Due to the record command hang fetch, the session locking scheme is further simplified to _one_ place for call backs (non_block_events). --- src/client.c | 8 -------- src/connection.c | 19 ++++++++++++++----- src/http_command.c | 5 ++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/client.c b/src/client.c index 439d103..077c77b 100644 --- a/src/client.c +++ b/src/client.c @@ -513,7 +513,6 @@ void client_check_preferred_watch(struct client *cl) { struct session *se = cl->session; - session_enter_ro(se, "client_check_preferred_watch"); yaz_log(YLOG_DEBUG, "client_check_preferred_watch: %s ", client_get_id(cl)); if (se) { @@ -527,7 +526,6 @@ void client_check_preferred_watch(struct client *cl) else yaz_log(YLOG_WARN, "client_check_preferred_watch: %s. No session!", client_get_id(cl)); - session_leave_ro(se, "client_check_preferred_watch"); } struct suggestions* client_suggestions_create(const char* suggestions_string); @@ -541,7 +539,6 @@ void client_search_response(struct client *cl) const char *error, *addinfo = 0; - session_enter_rw(cl->session, "client_search_response"); if (ZOOM_connection_error(link, &error, &addinfo)) { cl->hits = 0; @@ -559,14 +556,12 @@ void client_search_response(struct client *cl) client_suggestions_destroy(cl); cl->suggestions = client_suggestions_create(ZOOM_resultset_option_get(resultset, "suggestions")); } - session_leave_rw(cl->session, "client_search_response"); } void client_got_records(struct client *cl) { struct session *se = cl->session; - session_enter_ro(se, "client_got_records"); if (reclist_get_num_records(se->reclist) > 0) { session_alert_watch(se, SESSION_WATCH_SHOW); @@ -574,7 +569,6 @@ void client_got_records(struct client *cl) session_alert_watch(se, SESSION_WATCH_TERMLIST); session_alert_watch(se, SESSION_WATCH_RECORD); } - session_leave_ro(se, "client_got_records"); } static void client_record_ingest(struct client *cl) @@ -651,7 +645,6 @@ void client_record_response(struct client *cl, int *got_records) ZOOM_resultset resultset = cl->resultset; const char *error, *addinfo; - session_enter_rw(cl->session, "client_record_response"); if (ZOOM_connection_error(link, &error, &addinfo)) { client_set_state(cl, Client_Error); @@ -681,7 +674,6 @@ void client_record_response(struct client *cl, int *got_records) *got_records = 1; } } - session_leave_rw(cl->session, "client_record_response"); } int client_reingest(struct client *cl) diff --git a/src/connection.c b/src/connection.c index 4c0f0cc..ce9b46d 100644 --- a/src/connection.c +++ b/src/connection.c @@ -195,7 +195,7 @@ static struct connection *connection_create(struct client *cl, return co; } -static void non_block_events(struct connection *co) +static void non_block_events_unlocked(struct connection *co) { int got_records = 0; IOCHAN iochan = co->iochan; @@ -276,11 +276,20 @@ static void non_block_events(struct connection *co) } } +static void non_block_events(struct client *cl, struct connection *co) +{ + session_enter_rw(client_get_session(cl), "non_block_events"); + non_block_events_unlocked(co); + session_leave_rw(client_get_session(cl), "non_block_events"); +} + void connection_continue(struct connection *co) { int r = ZOOM_connection_exec_task(co->link); if (!r) - non_block_events(co); + { + non_block_events_unlocked(co); + } else { iochan_setflags(co->iochan, ZOOM_connection_get_mask(co->link)); @@ -310,7 +319,7 @@ static void connection_handler(IOCHAN iochan, int event) { ZOOM_connection_fire_event_timeout(co->link); - non_block_events(co); + non_block_events(cl, co); remove_connection_from_host(co); yaz_mutex_leave(host->mutex); @@ -320,11 +329,11 @@ static void connection_handler(IOCHAN iochan, int event) { yaz_mutex_leave(host->mutex); - non_block_events(co); + non_block_events(cl, co); ZOOM_connection_fire_event_socket(co->link, event); - non_block_events(co); + non_block_events(cl, co); if (co->link) { diff --git a/src/http_command.c b/src/http_command.c index 4f6c5c2..cf7ab9b 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1098,7 +1098,6 @@ static void show_records(struct http_channel *c, struct http_session *s, int act if (!s) return; - session_enter_ro(s->psession, "show_records"); // We haven't counted clients yet if we're called on a block release if (active < 0) active = session_active_clients(s->psession); @@ -1115,7 +1114,6 @@ static void show_records(struct http_channel *c, struct http_session *s, int act if (!(sp = reclist_parse_sortparms(c->nmem, sort, service))) { error(rs, PAZPAR2_MALFORMED_PARAMETER_VALUE, "sort"); - session_leave_ro(s->psession, "show_records"); return; } @@ -1162,7 +1160,6 @@ static void show_records(struct http_channel *c, struct http_session *s, int act } show_range_stop(s->psession, rl); - session_leave_ro(s->psession, "show_records"); response_close(c, "show"); } @@ -1266,7 +1263,9 @@ static void cmd_show(struct http_channel *c) } } } + session_enter_ro(s->psession, "show_records"); show_records(c, s, status); + session_leave_ro(s->psession, "show_records"); release_session(c, s); } -- 1.7.10.4