From: Adam Dickmeiss Date: Mon, 8 Sep 2014 12:32:53 +0000 (+0200) Subject: Add session lock for command=settings PAZ-960 X-Git-Tag: v1.7.5~8 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=9c7160ee28a1542ec39f024cc60e39e163a920d1;p=pazpar2-moved-to-github.git Add session lock for command=settings PAZ-960 --- diff --git a/src/session.c b/src/session.c index 2823399..5cba1d6 100644 --- a/src/session.c +++ b/src/session.c @@ -908,35 +908,36 @@ static struct session_database *find_session_database(struct session *se, void session_apply_setting(struct session *se, char *dbname, char *name, char *value) { - struct session_database *sdb = find_session_database(se, dbname); - struct conf_service *service = se->service; - struct setting *s; - int offset = settings_create_offset(service, name); - - expand_settings_array(&sdb->settings, &sdb->num_settings, offset, - se->session_nmem); - - // Force later recompute of settings-driven data structures - // (happens when a search starts and client connections are prepared) - if (offset == PZ_XSLT) - sdb->map = 0; - - se->settings_modified = 1; - for (s = sdb->settings[offset]; s; s = s->next) - if (!strcmp(s->name, name) && - dbname && s->target && !strcmp(dbname, s->target)) + session_enter(se, "session_apply_setting"); + { + struct session_database *sdb = find_session_database(se, dbname); + struct conf_service *service = se->service; + struct setting *s; + int offset = settings_create_offset(service, name); + + expand_settings_array(&sdb->settings, &sdb->num_settings, offset, + se->session_nmem); + // Force later recompute of settings-driven data structures + // (happens when a search starts and client connections are prepared) + if (offset == PZ_XSLT) + sdb->map = 0; + se->settings_modified = 1; + for (s = sdb->settings[offset]; s; s = s->next) + if (!strcmp(s->name, name) && + dbname && s->target && !strcmp(dbname, s->target)) + break; + if (!s) { - s->value = value; - return; + s = nmem_malloc(se->session_nmem, sizeof(*s)); + s->precedence = 0; + s->target = dbname; + s->name = name; + s->next = sdb->settings[offset]; + sdb->settings[offset] = s; } - s = nmem_malloc(se->session_nmem, sizeof(*s)); - s->precedence = 0; - s->target = dbname; - s->name = name; - s->value = value; - s->next = sdb->settings[offset]; - sdb->settings[offset] = s; - + s->value = value; + } + session_leave(se, "session_apply_setting"); } void session_destroy(struct session *se)