aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authoronefang2021-09-09 17:30:46 +1000
committeronefang2021-09-09 17:30:46 +1000
commitc03d01ebd66ae3eeed4cce4baa3e6e7cdb07e73d (patch)
tree6f5e124ee73957b63f1bedbeba8f17ae431b89e7
parentOnly free it once. (diff)
downloadopensim-SC-c03d01ebd66ae3eeed4cce4baa3e6e7cdb07e73d.zip
opensim-SC-c03d01ebd66ae3eeed4cce4baa3e6e7cdb07e73d.tar.gz
opensim-SC-c03d01ebd66ae3eeed4cce4baa3e6e7cdb07e73d.tar.bz2
opensim-SC-c03d01ebd66ae3eeed4cce4baa3e6e7cdb07e73d.tar.xz
If there's no sims, don't bother calculating area of all sims.
-rw-r--r--src/sledjchisl/sledjchisl.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index 9ed7ba1..d18c73e 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -4015,56 +4015,62 @@ gridStats *getStats(MYSQL *db, gridStats *stats)
4015 replaceLong(stats->stats, "day60", HGin); 4015 replaceLong(stats->stats, "day60", HGin);
4016 replaceLong(stats->stats, "HGday60", HGin - locIn); 4016 replaceLong(stats->stats, "HGday60", HGin - locIn);
4017 4017
4018 my_ulonglong sims = dbCount("regions", NULL);
4018 // Collect stats about sims. 4019 // Collect stats about sims.
4019 replaceLong(stats->stats, "sims", dbCount("regions", NULL)); 4020 replaceLong(stats->stats, "sims", sims);
4020 replaceLong(stats->stats, "onlineSims", dbCount("regions", "sizeX != 0")); 4021 replaceLong(stats->stats, "onlineSims", dbCount("regions", "sizeX != 0"));
4021 replaceLong(stats->stats, "varRegions", dbCount("regions", "sizeX > 256 or sizeY > 256")); 4022 replaceLong(stats->stats, "varRegions", dbCount("regions", "sizeX > 256 or sizeY > 256"));
4022 replaceLong(stats->stats, "singleSims", dbCount("regions", "sizeX = 256 and sizeY = 256")); 4023 replaceLong(stats->stats, "singleSims", dbCount("regions", "sizeX = 256 and sizeY = 256"));
4023 replaceLong(stats->stats, "offlineSims", dbCount("regions", "sizeX = 0")); 4024 replaceLong(stats->stats, "offlineSims", dbCount("regions", "sizeX = 0"));
4024 4025
4025 // Calculate total size of all regions. 4026 if (0 < sims)
4026 my_ulonglong simSize = 0;
4027 static dbRequest *rgnSizes = NULL;
4028 if (NULL == rgnSizes)
4029 { 4027 {
4030 static char *szi[] = {NULL}; 4028 // Calculate total size of all regions.
4031 static char *szo[] = {"sizeX", "sizeY", NULL}; 4029 my_ulonglong simSize = 0;
4032 rgnSizes = xzalloc(sizeof(dbRequest)); 4030 static dbRequest *rgnSizes = NULL;
4033 rgnSizes->table = "regions"; 4031 if (NULL == rgnSizes)
4034 rgnSizes->inParams = szi; 4032 {
4035 rgnSizes->outParams = szo; 4033 static char *szi[] = {NULL};
4036 rgnSizes->where = "sizeX != 0"; 4034 static char *szo[] = {"sizeX", "sizeY", NULL};
4037 dbRequests->addfirst(dbRequests, &rgnSizes, sizeof(dbRequest *)); 4035 rgnSizes = xzalloc(sizeof(dbRequest));
4038 } 4036 rgnSizes->table = "regions";
4039 dbDoSomething(rgnSizes, FALSE); // LEAKY 4037 rgnSizes->inParams = szi;
4040 rowData *rows = rgnSizes->rows; 4038 rgnSizes->outParams = szo;
4039 rgnSizes->where = "sizeX != 0";
4040 dbRequests->addfirst(dbRequests, &rgnSizes, sizeof(dbRequest *));
4041 }
4042 dbDoSomething(rgnSizes, FALSE); // LEAKY
4043 rowData *rows = rgnSizes->rows;
4041 4044
4042 qhashtbl_t *row; 4045 qhashtbl_t *row;
4043 while (NULL != (row = rows->rows->getat(rows->rows, 0, NULL, true))) 4046 while (NULL != (row = rows->rows->getat(rows->rows, 0, NULL, true)))
4044 { 4047 {
4045 my_ulonglong x = 0, y = 0; 4048 my_ulonglong x = 0, y = 0;
4046 4049
4047 tmp = row->getstr(row, "sizeX", false); 4050 tmp = row->getstr(row, "sizeX", false);
4048 if (NULL == tmp) 4051 if (NULL == tmp)
4049 E("No regions.sizeX!"); 4052 E("No regions.sizeX!");
4050 else 4053 else
4051 x = atoll(tmp); 4054 x = atoll(tmp);
4052 tmp = row->getstr(row, "sizeY", false); 4055 tmp = row->getstr(row, "sizeY", false);
4053 if (NULL == tmp) 4056 if (NULL == tmp)
4054 E("No regions.sizeY!"); 4057 E("No regions.sizeY!");
4055 else 4058 else
4056 y = atoll(tmp); 4059 y = atoll(tmp);
4057 simSize += x * y; 4060 simSize += x * y;
4058 row->free(row); 4061 row->free(row);
4059 rows->rows->removefirst(rows->rows); 4062 rows->rows->removefirst(rows->rows);
4060 } 4063 }
4061 free(rows->fieldNames); 4064 free(rows->fieldNames);
4062 rows->rows->free(rows->rows); 4065 rows->rows->free(rows->rows);
4063 free(rows); 4066 free(rows);
4064 4067
4065 tmp = xmprintf("%lu", simSize); 4068 tmp = xmprintf("%lu", simSize);
4066 stats->stats->putstr(stats->stats, "simsSize", tmp); 4069 stats->stats->putstr(stats->stats, "simsSize", tmp);
4067 free(tmp); 4070 free(tmp);
4071 }
4072 else
4073 stats->stats->putstr(stats->stats, "simsSize", "0");
4068 gettimeofday(&(stats->last), NULL); 4074 gettimeofday(&(stats->last), NULL);
4069 4075
4070 return stats; 4076 return stats;