Commit 1b2a65f4 authored by Marc Welz's avatar Marc Welz
Browse files

Bugfix: retrieve the correct parse message from a notice (for callbacks)

parent f67dddf2
Showing with 29 additions and 8 deletions
+29 -8
......@@ -686,6 +686,10 @@ static int field_job_katcp(struct katcp_dispatch *d, struct katcp_job *j)
struct katcp_notice *n;
struct katcl_parse *p;
struct katcp_trap *kt;
#ifdef DEBUG
int i;
char *tmp;
#endif
while((result = have_katcl(j->j_line)) > 0){
......@@ -695,7 +699,15 @@ static int field_job_katcp(struct katcp_dispatch *d, struct katcp_job *j)
}
#ifdef DEBUG
fprintf(stderr, "job: processing message starting with <%s ..>\n", cmd);
p = ready_katcl(j->j_line);
fprintf(stderr, "job: processing message starting with <%s %s ...>\n", cmd, arg_string_katcl(j->j_line, 1));
fprintf(stderr, "job: alt:");
for(i = 0; (tmp = get_string_parse_katcl(p, i)); i++){
fprintf(stderr, " <%s>", tmp);
}
fprintf(stderr, "\n");
#endif
switch(cmd[0]){
......
......@@ -2466,6 +2466,10 @@ int match_sensor_list_katcp(struct katcp_dispatch *d, struct katcp_notice *n, vo
units = get_string_parse_katcl(p, 3);
type = get_string_parse_katcl(p, 4);
#ifdef DEBUG
fprintf(stderr, "sensor: saw sensor %s, type %s\n", name, type);
#endif
if((name == NULL) ||
(description == NULL) ||
(type == NULL)){
......
......@@ -601,16 +601,13 @@ void release_notice_katcp(struct katcp_dispatch *d, struct katcp_notice *n)
struct katcl_parse *get_parse_notice_katcp(struct katcp_dispatch *d, struct katcp_notice *n)
{
struct katcl_parse *p;
sane_notice_katcp(n);
p = get_head_queue_katcl(n->n_queue);
if(p){
return p;
if(n->n_parse){
return n->n_parse;
}
return n->n_parse;
return get_head_queue_katcl(n->n_queue);
#if 0
if(n->n_position < 0){
......@@ -871,6 +868,10 @@ int run_notices_katcp(struct katcp_dispatch *d)
n->n_parse = NULL;
}
#ifdef DEBUG
fprintf(stderr, "notice: notice %p triggered with %d messages and %d subscribers\n", n, limit, n->n_count);
#endif
/* WARNING: vague semantics ahead. What does it mean to only have woken a single call back which then clears the set of parse messages ? */
n->n_parse = remove_head_queue_katcl(n->n_queue);
......@@ -883,6 +884,10 @@ int run_notices_katcp(struct katcp_dispatch *d)
v->v_trigger = 0;
result = (*(v->v_call))(v->v_client, n, v->v_data);
#ifdef DEBUG
fprintf(stderr, "notice: notice %p callback[%d]=%p returns %d (parse=%p)\n", n, k, v->v_call, result, n->n_parse);
#endif
if(result <= 0){
dispatch_compact_notice_katcp(v->v_client, n);
......
......@@ -130,7 +130,7 @@ int add_tail_queue_katcl(struct katcl_queue *q, struct katcl_parse *p)
}
#ifdef DEBUG
fprintf(stderr, "add queue: adding %p with ref %u\n", p, p->p_refs);
fprintf(stderr, "add queue: adding %p with ref %u to queue %p of size %d\n", p, p->p_refs, q, q->q_count);
#endif
if(q->q_count >= q->q_size){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment