From: Dennis Schafroth Date: Thu, 3 Nov 2011 14:47:29 +0000 (+0100) Subject: Merge branch 'bytarget_block' of ssh://git.indexdata.com/home/git/pub/pazpar2 into... X-Git-Tag: mobile-beta-1~18^2~3 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=fc794a5a4623194e7e5cff1ea63ecdc80575312e;hp=950f9ae98a1342eba4845091cc65bdfc45dd275b;p=pazpar2-moved-to-github.git Merge branch 'bytarget_block' of ssh://git.indexdata.com/home/git/pub/pazpar2 into bytarget_block Conflicts: src/http_command.c Added on two machines --- diff --git a/.cproject b/.cproject index be8b449..370e803 100644 --- a/.cproject +++ b/.cproject @@ -22,7 +22,7 @@ - + @@ -50,255 +50,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -346,255 +97,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -602,4 +104,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project index abaaf39..6884081 100644 --- a/.project +++ b/.project @@ -63,7 +63,7 @@ org.eclipse.cdt.make.core.useDefaultBuildCmd - true + false diff --git a/src/client.c b/src/client.c index ac5bda6..b5ef75d 100644 --- a/src/client.c +++ b/src/client.c @@ -1189,7 +1189,7 @@ const char * client_get_suggestions_xml(struct client *cl, WRBUF wrbuf) struct suggestions *suggestions = cl->suggestions; if (!suggestions) { - yaz_log(YLOG_DEBUG, "No suggestions found"); + //yaz_log(YLOG_DEBUG, "No suggestions found"); return ""; } if (suggestions->passthrough) { diff --git a/src/http_command.c b/src/http_command.c index 8ba4b15..d4970a4 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -509,7 +509,7 @@ static void cmd_settings(struct http_channel *c) release_session(c, s); } -static void cmd_termlist(struct http_channel *c) +static void termlist_response(struct http_channel *c) { struct http_request *rq = c->request; struct http_session *s = locate_session(c); @@ -518,14 +518,11 @@ static void cmd_termlist(struct http_channel *c) int num = 15; int status; - if (!s) - return; - - status = session_active_clients(s->psession); - if (nums) num = atoi(nums); + status = session_active_clients(s->psession); + response_open_no_status(c, "termlist"); wrbuf_printf(c->wrbuf, "%d\n", status); @@ -535,6 +532,45 @@ static void cmd_termlist(struct http_channel *c) release_session(c, s); } +static void termlist_result_ready(void *data) +{ + struct http_channel *c = (struct http_channel) data; + termlist_response(c); +} + +static void cmd_termlist(struct http_channel *c) +{ + struct http_request *rq = c->request; + struct http_response *rs = c->response; + struct http_session *s = locate_session(c); + const char *block = http_argbyname(rq, "block"); + int active_clients; + if (!s) + return; + + active_clients = session_active_clients(s->psession); + + if (block && !strcmp("1", block) && active_clients) + { + // if there is already a watch/block. we do not block this one + if (session_set_watch(s->psession, SESSION_WATCH_TERMLIST, + termlist_result_ready, c, c) != 0) + { + yaz_log(YLOG_WARN, "Attempt to block multiple times on termlist block. Not supported!"); + error(rs, PAZPAR2_ALREADY_BLOCKED, "termlist"); + } + else + { + yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on command termlist", s, s->session_id); + } + release_session(c, s); + return; + } + + termlist_response(c); + release_session(c, s); +} + size_t session_get_memory_status(struct session *session); static void session_status(struct http_channel *c, struct http_session *s) @@ -665,11 +701,14 @@ static void cmd_bytarget(struct http_channel *c) struct http_response *rs = c->response; struct http_session *s = locate_session(c); const char *block = http_argbyname(rq, "block"); + int no_active; if (!s) return; - if (block && strcmp("1",block) == 0) + no_active = session_active_clients(s->psession); + + if (block && !strcmp("1",block) && no_active) { // if there is already a watch/block. we do not block this one if (session_set_watch(s->psession, SESSION_WATCH_BYTARGET, diff --git a/src/session.h b/src/session.h index 4b24df5..3255ac3 100644 --- a/src/session.h +++ b/src/session.h @@ -76,7 +76,8 @@ struct session_database #define SESSION_WATCH_SHOW 0 #define SESSION_WATCH_RECORD 1 #define SESSION_WATCH_SHOW_PREF 2 -#define SESSION_WATCH_BYTARGET 3 +#define SESSION_WATCH_TERMLIST 3 +#define SESSION_WATCH_BYTARGET 4 #define SESSION_WATCH_MAX 3 #define SESSION_MAX_TERMLISTS 10