xmlFree(result);
}
-static void session_enter(struct session *s, const char *caller)
+void session_enter_ro(struct session *s, const char *caller)
{
+ assert(s);
+ if (caller)
+ session_log(s, YLOG_LOG, "Session read lock by %s", caller);
+ pazpar2_lock_rdwr_rlock(&s->lock);
+}
+
+void session_enter_rw(struct session *s, const char *caller)
+{
+ assert(s);
+ if (caller)
+ session_log(s, YLOG_LOG, "Session write lock by %s", caller);
+ pazpar2_lock_rdwr_wlock(&s->lock);
+}
+
+void session_upgrade(struct session *s, const char *caller)
+{
+ assert(s);
+ if (caller)
+ session_log(s, YLOG_LOG, "Session upgrade lock by %s", caller);
+ pazpar2_lock_rdwr_upgrade(&s->lock);
+}
+
+void session_leave_ro(struct session *s, const char *caller)
+{
+ assert(s);
+ if (caller)
+ session_log(s, YLOG_LOG, "Session read unlock by %s", caller);
+ pazpar2_lock_rdwr_runlock(&s->lock);
+}
+
+void session_leave_rw(struct session *s, const char *caller)
+{
+ assert(s);
if (caller)
- session_log(s, YLOG_DEBUG, "Session lock by %s", caller);
- yaz_mutex_enter(s->session_mutex);
+ session_log(s, YLOG_LOG, "Session write unlock by %s", caller);
+ pazpar2_lock_rdwr_wunlock(&s->lock);
}
-static void session_leave(struct session *s, const char *caller)
+void session_downgrade(struct session *s, const char *caller)
{
- yaz_mutex_leave(s->session_mutex);
+ assert(s);
if (caller)
- session_log(s, YLOG_DEBUG, "Session unlock by %s", caller);
+ session_log(s, YLOG_LOG, "Session write unlock by %s", caller);
+ pazpar2_lock_rdwr_downgrade(&s->lock);
}
- static void session_normalize_facet(struct session *s, const char *type,
- const char *value,
- WRBUF display_wrbuf,
- WRBUF facet_wrbuf)
+ static void session_normalize_facet(struct session *s,
+ const char *type, const char *value,
+ WRBUF display_wrbuf, WRBUF facet_wrbuf)
{
struct conf_service *service = s->service;
pp2_charset_token_t prt;
}
}
- void session_sort(struct session *se, struct reclist_sortparms *sp)
+ void session_sort(struct session *se, struct reclist_sortparms *sp,
+ const char *mergekey, const char *rank)
{
- //session_enter(se, "session_sort");
+ session_enter_rw(se, "session_sort");
- session_sort_unlocked(se, sp);
+ session_sort_unlocked(se, sp, mergekey, rank);
- //session_leave(se, "session_sort");
+ session_leave_rw(se, "session_sort");
}
-
-enum pazpar2_error_code session_search(struct session *se,
- const char *query,
- const char *startrecs,
- const char *maxrecs,
- const char *filter,
- const char *limit,
- const char **addinfo,
- struct reclist_sortparms *sp,
- const char *mergekey,
- const char *rank)
+static
+enum pazpar2_error_code session_search_unlocked(struct session *se,
+ const char *query,
+ const char *startrecs,
+ const char *maxrecs,
+ const char *filter,
+ const char *limit,
+ const char **addinfo,
- struct reclist_sortparms *sp)
++ struct reclist_sortparms *sp,
++ const char *mergekey,
++ const char *rank)
{
int live_channels = 0;
int no_working = 0;
else
session_reset_active_clients(se, 0);
- session_enter(se, "session_search");
se->settings_modified = 0;
+ if (mergekey)
+ {
+ xfree(se->mergekey);
+ se->mergekey = *mergekey ? xstrdup(mergekey) : 0;
+ }
+ if (rank)
+ {
+ xfree(se->rank);
+ se->rank = *rank ? xstrdup(rank) : 0;
+ }
+
session_clear_set(se, sp);
relevance_destroy(&se->relevance);
return PAZPAR2_NO_ERROR;
}
+enum pazpar2_error_code session_search(struct session *se,
+ const char *query,
+ const char *startrecs,
+ const char *maxrecs,
+ const char *filter,
+ const char *limit,
+ const char **addinfo,
- struct reclist_sortparms *sp)
++ struct reclist_sortparms *sp,
++ const char *mergekey,
++ const char *rank)
+{
+ enum pazpar2_error_code c;
+ session_enter_rw(se, "session_search");
+ c = session_search_unlocked(se, query, startrecs, maxrecs, filter,
- limit, addinfo, sp);
++ limit, addinfo, sp, mergekey, rank);
+ session_leave_rw(se, "session_search");
+ return c;
+}
+
// Creates a new session_database object for a database
static void session_init_databases_fun(void *context, struct database *db)
{