patched ALL query
authorJiří Filipovič <fila@ics.muni.cz>
Tue, 12 Oct 2010 13:14:47 +0000 (13:14 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Tue, 12 Oct 2010 13:14:47 +0000 (13:14 +0000)
org.glite.lb.server/src/stats.c

index 41edb2e..96e7080 100644 (file)
@@ -714,7 +714,7 @@ int edg_wll_StateRateServer(
 {
        edg_wll_Stats *stats = default_stats;   /* XXX: hardcoded */
        struct edg_wll_stats_group    *g;
-       int     i;
+       int     i, shift;
        char    *sig = NULL;    
        int     err;
 
@@ -766,15 +766,19 @@ int edg_wll_StateRateServer(
                /* all groups */
                *rates = (float*)malloc(stats->grpno * sizeof((*rates)[0]));
                *groups = (char**)malloc((stats->grpno+1) * sizeof((*groups)[0]));
+               shift = 0;
                for (i=0, g=stats->map; i<stats->grpno; i++) {
-                       (*rates)[i] = 0;
-                       (*groups)[i] = NULL;
-                       if ((err = stateRateRequest(ctx, stats, g, from, to, &((*rates)[i]), res_from, res_to)))
-                               continue; //TODO in fact breaks results here
-                       (*groups)[i] = strdup(g->destination);
+                       (*rates)[i-shift] = 0;
+                       (*groups)[i-shift] = NULL;
+                       if ((err = stateRateRequest(ctx, stats, g, from, to, &((*rates)[i-shift]), res_from, res_to))){
+                               shift++;
+                               g = (struct edg_wll_stats_group *) (((char *) g) + stats->grpsize);
+                               continue;
+                       }
+                       (*groups)[i-shift] = strdup(g->destination);
                        g = (struct edg_wll_stats_group *) (((char *) g) + stats->grpsize);
                 }
-               (*groups)[i] = NULL;
+               (*groups)[i-shift] = NULL;
                if (i == 0){
                        edg_wll_SetError(ctx,ENOENT,"no matching group");
                         free(*rates); *rates = NULL;
@@ -948,7 +952,7 @@ int edg_wll_StateDurationFromToServer(
         struct edg_wll_stats_group      *g;
         char    *sig = NULL;
        int     err;
-       int     i;
+       int     i, shift;
 
         edg_wll_ResetError(ctx);
        *durations = NULL;
@@ -1001,17 +1005,21 @@ int edg_wll_StateDurationFromToServer(
                *durations = (float*)malloc(stats->grpno * sizeof((*durations)[0]));
                *dispersions = (float*)malloc(stats->grpno * sizeof((*dispersions)[0]));
                *groups = (char**)malloc((stats->grpno+1) * sizeof((*groups)[0]));
+               shift = 0;
 
                for (i=0, g=stats->map; i<stats->grpno; i++) {
-                       (*durations)[i] = 0;
-                       (*dispersions)[i] = 0;
-                       (*groups)[i] = NULL;
-                       if ((err = stateDurationFromToRequest(ctx, stats, g, from, to, &((*durations)[i]), &((*dispersions)[i]), res_from, res_to)))
-                               continue; //TODO in fact breaks results here
-                       (*groups)[i] = strdup(g->destination);
+                       (*durations)[i-shift] = 0;
+                       (*dispersions)[i-shift] = 0;
+                       (*groups)[i-shift] = NULL;
+                       if ((err = stateDurationFromToRequest(ctx, stats, g, from, to, &((*durations)[i-shift]), &((*dispersions)[i-shift]), res_from, res_to))){
+                               shift++;
+                               g = (struct edg_wll_stats_group *) (((char *) g) + stats->grpsize);
+                               continue;
+                       }
+                       (*groups)[i-shift] = strdup(g->destination);
                        g = (struct edg_wll_stats_group *) (((char *) g) + stats->grpsize);
                }
-               (*groups)[i] = NULL;
+               (*groups)[i-shift] = NULL;
                 if (i == 0){
                         edg_wll_SetError(ctx,ENOENT,"no matching group");
                         free(*durations); *durations = NULL;