From: František Dvořák Date: Thu, 26 Jul 2012 07:32:25 +0000 (+0000) Subject: End of notification stream also when error occures. Preventively keep ending item... X-Git-Tag: glite-jobid-api-c_R_2_1_2_3~2 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=7bf14e158f4690c447596577ea8065e16053f92f;p=jra1mw.git End of notification stream also when error occures. Preventively keep ending item in the array anyway. --- diff --git a/org.glite.lb.server/src/query.c b/org.glite.lb.server/src/query.c index 859d3a6..abd676f 100644 --- a/org.glite.lb.server/src/query.c +++ b/org.glite.lb.server/src/query.c @@ -359,24 +359,30 @@ static int queryjobs_cb(edg_wll_Context ctx, glite_jobid_t jobid, edg_wll_JobSta size_t maxn = store->maxn; void *tmp; - if (n >= maxn) { + // one more item for the array ending shouldn't be needed, + // only preventively here + if (n + 1 >= maxn) { maxn = maxn ? maxn << 1 : 256; - if ((tmp = realloc(store->jobs, maxn * sizeof(*store->jobs))) == NULL) + if ((tmp = realloc(store->jobs, (maxn + 1) * sizeof(*store->jobs))) == NULL) return edg_wll_SetError(ctx, errno ? : ENOMEM, NULL); store->jobs = tmp; if (!(store->flags & EDG_WLL_STAT_NO_STATES)) { - if ((tmp = realloc(store->states, maxn * sizeof(*store->states))) == NULL) + if ((tmp = realloc(store->states, (maxn + 1) * sizeof(*store->states))) == NULL) return edg_wll_SetError(ctx, errno ? : ENOMEM, NULL); store->states = tmp; } store->maxn = maxn; } + store->jobs[n] = jobid; + store->jobs[n + 1] = NULL; + if (!(store->flags & EDG_WLL_STAT_NO_STATES)) { if (status) store->states[n] = *status; else memset(&store->states[n], 0, sizeof(*store->states)); + memset(&store->states[n + 1], 0, sizeof(*store->states)); } store->n++; @@ -675,10 +681,10 @@ limit_cycle_cleanup: } } +cleanup: // finish cb(ctx, NULL, NULL, data); -cleanup: free(qbase); free(state_where); free(tags_where);