From 7bf14e158f4690c447596577ea8065e16053f92f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 26 Jul 2012 07:32:25 +0000 Subject: [PATCH] End of notification stream also when error occures. Preventively keep ending item in the array anyway. --- org.glite.lb.server/src/query.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); -- 1.8.2.3