several fixes in server stats and configurations
authorJiří Filipovič <fila@ics.muni.cz>
Wed, 29 Feb 2012 13:53:34 +0000 (13:53 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Wed, 29 Feb 2012 13:53:34 +0000 (13:53 +0000)
org.glite.lb.server/src/lb_text.c
org.glite.lb.server/src/server_stats.c

index 800de5a..75fd249 100644 (file)
@@ -282,7 +282,7 @@ int edg_wll_JobStatusToText(edg_wll_Context ctx UNUSED_VAR, edg_wll_JobStat stat
 int edg_wll_ConfigurationToText(edg_wll_Context ctx, int admin, char **message){
        char *a = NULL, *b;
        int pomL = 0;
-       int i;
+       int i = 0;
        b = strdup("");
 
        TRS("server_version", "%s\n", VERSION);
@@ -329,12 +329,14 @@ int edg_wll_ConfigurationToText(edg_wll_Context ctx, int admin, char **message){
                int fd;
                if (ctx->authz_policy_file && (fd = open(ctx->authz_policy_file, O_RDONLY)) >= 0){
                        off_t size = lseek(fd, 0, SEEK_END) - lseek(fd, 0, SEEK_SET);
-                       char *pft = (char*)calloc(sizeof(char), size);
-                       read(fd, pft, size);
-                       close(fd);
-                       pf = escape_text(pft);
-// Why not             trio_asprintf(&pf, "%|Js", pft);
-                       free(pft);
+                       if (size){
+                               char *pft = (char*)calloc(sizeof(char), size);
+                               read(fd, pft, size);
+                               close(fd);
+                               pf = escape_text(pft);
+// Why not                     trio_asprintf(&pf, "%|Js", pft);
+                               free(pft);
+                       }
                }
                TRS("authz_policy_file", "%s\n", pf);
                free(pf);
index fdb0612..1fc04fd 100644 (file)
@@ -84,11 +84,10 @@ int edg_wll_InitServerStatistics(edg_wll_Context ctx, char *prefix)
        }
 
        // read and mmap statistics
-       read(serverStatisticsFD, serverStatisticsMap, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap));
-        serverStatisticsMap = mmap(NULL, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap), PROT_READ|PROT_WRITE, MAP_SHARED, serverStatisticsFD, 0);
+       serverStatisticsMap = mmap(NULL, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap), PROT_READ|PROT_WRITE, MAP_SHARED, serverStatisticsFD, 0);
         if (serverStatisticsMap == MAP_FAILED) return edg_wll_SetError(ctx,errno,"mmap()");
-
-       msync(serverStatisticsMap, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap), MS_ASYNC);
+       read(serverStatisticsFD, serverStatisticsMap, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap));
+//     msync(serverStatisticsMap, SERVER_STATISTICS_COUNT*sizeof(*serverStatisticsMap), MS_ASYNC);
 
        free(fname);