projects
/
pazpar2-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c46c217
)
Fix: Send error response if set block fails.
author
Dennis Schafroth
<dennis@indexdata.com>
Thu, 3 Nov 2011 12:18:43 +0000
(13:18 +0100)
committer
Dennis Schafroth
<dennis@indexdata.com>
Thu, 3 Nov 2011 12:18:43 +0000
(13:18 +0100)
src/http_command.c
patch
|
blob
|
history
diff --git
a/src/http_command.c
b/src/http_command.c
index
1d47702
..
8a13590
100644
(file)
--- a/
src/http_command.c
+++ b/
src/http_command.c
@@
-229,6
+229,7
@@
static const char *get_msg(enum pazpar2_error_code code)
{ PAZPAR2_RECORD_FAIL, "Record command failed"},
{ PAZPAR2_NOT_IMPLEMENTED, "Not implemented"},
{ PAZPAR2_NO_SERVICE, "No service"},
{ PAZPAR2_RECORD_FAIL, "Record command failed"},
{ PAZPAR2_NOT_IMPLEMENTED, "Not implemented"},
{ PAZPAR2_NO_SERVICE, "No service"},
+ { PAZPAR2_ALREADY_BLOCKED, "Already blocked on command in session."},
{ PAZPAR2_LAST_ERROR, "Last error"},
{ 0, 0 }
};
{ PAZPAR2_LAST_ERROR, "Last error"},
{ 0, 0 }
};
@@
-320,8
+321,8
@@
unsigned int make_sessionid(void)
static struct http_session *locate_session(struct http_channel *c)
{
static struct http_session *locate_session(struct http_channel *c)
{
- struct http_response *rs = c->response;
struct http_request *rq = c->request;
struct http_request *rq = c->request;
+ struct http_response *rs = c->response;
struct http_session *p;
const char *session = http_argbyname(rq, "session");
http_sessions_t http_sessions = c->http_sessions;
struct http_session *p;
const char *session = http_argbyname(rq, "session");
http_sessions_t http_sessions = c->http_sessions;
@@
-660,20
+661,24
@@
static void bytarget_result_ready(void *data)
static void cmd_bytarget(struct http_channel *c)
{
struct http_request *rq = c->request;
static void cmd_bytarget(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");
struct http_session *s = locate_session(c);
const char *block = http_argbyname(rq, "block");
- struct hitsbytarget *ht;
if (!s)
return;
if (!s)
return;
- if (block && strcmp("1",*block) == 0)
+ if (block && strcmp("1",block) == 0)
{
// if there is already a watch/block. we do not block this one
if (session_set_watch(s->psession, SESSION_WATCH_BYTARGET,
bytarget_result_ready, c, c) != 0)
{
{
// if there is already a watch/block. we do not block this one
if (session_set_watch(s->psession, SESSION_WATCH_BYTARGET,
bytarget_result_ready, c, c) != 0)
{
- yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on cmd_bytarget", s, s->session_id);
+ error(rs, PAZPAR2_ALREADY_BLOCKED, "bytarget");
+ }
+ else
+ {
+ yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on command bytarget", s, s->session_id);
}
release_session(c, s);
return;
}
release_session(c, s);
return;
@@
-982,7
+987,8
@@
static void show_records_ready(void *data)
static void cmd_show(struct http_channel *c)
{
static void cmd_show(struct http_channel *c)
{
- struct http_request *rq = c->request;
+ 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");
const char *sort = http_argbyname(rq, "sort");
struct http_session *s = locate_session(c);
const char *block = http_argbyname(rq, "block");
const char *sort = http_argbyname(rq, "sort");
@@
-1011,10
+1017,14
@@
static void cmd_show(struct http_channel *c)
{
// if there is already a watch/block. we do not block this one
if (session_set_watch(s->psession, SESSION_WATCH_SHOW_PREF,
{
// if there is already a watch/block. we do not block this one
if (session_set_watch(s->psession, SESSION_WATCH_SHOW_PREF,
- show_records_ready, c, c) != 0)
+ show_records_ready, c, c) == 0)
{
yaz_log(c->http_sessions->log_level,
{
yaz_log(c->http_sessions->log_level,
- "%p Session %u: Blocking on cmd_show. Waiting for preferred targets", s, s->session_id);
+ "%p Session %u: Blocking on command show (preferred targets)", s, s->session_id);
+ }
+ else
+ {
+ error(rs, PAZPAR2_ALREADY_BLOCKED, "show (preferred targets)");
}
release_session(c, s);
return;
}
release_session(c, s);
return;
@@
-1026,7
+1036,11
@@
static void cmd_show(struct http_channel *c)
if (session_set_watch(s->psession, SESSION_WATCH_SHOW,
show_records_ready, c, c) != 0)
{
if (session_set_watch(s->psession, SESSION_WATCH_SHOW,
show_records_ready, c, c) != 0)
{
- yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on cmd_show", s, s->session_id);
+ error(rs, PAZPAR2_ALREADY_BLOCKED, "show");
+ }
+ else
+ {
+ yaz_log(c->http_sessions->log_level, "%p Session %u: Blocking on command show", s, s->session_id);
}
release_session(c, s);
return;
}
release_session(c, s);
return;