diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-04-18 10:28:19 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-04-18 10:28:19 +0000 |
commit | c3f553e4116aacac5301316d364cef61b9d7f3e6 (patch) | |
tree | a2b1b1b032fb233ea80042b4f804ec59d2e0d2ee /src/regex | |
parent | 82d41c577fba27be3798bc477d6e99d1fda40d49 (diff) | |
download | gnunet-c3f553e4116aacac5301316d364cef61b9d7f3e6.tar.gz gnunet-c3f553e4116aacac5301316d364cef61b9d7f3e6.zip |
- move initializtion to run()
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 07749c5ec..8206d3e5b 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -1127,7 +1127,20 @@ test_master (void *cls, | |||
1127 | { | 1127 | { |
1128 | unsigned int i; | 1128 | unsigned int i; |
1129 | 1129 | ||
1130 | for (i = 0; i < num_peers; i++) | 1130 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
1131 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1132 | "Testbed started in %s\n", | ||
1133 | GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO)); | ||
1134 | |||
1135 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | ||
1136 | { | ||
1137 | GNUNET_SCHEDULER_cancel (abort_task); | ||
1138 | abort_task = GNUNET_SCHEDULER_NO_TASK; | ||
1139 | } | ||
1140 | |||
1141 | for (i = 0; i < num_peers; i++) | ||
1142 | { | ||
1143 | } | ||
1131 | GNUNET_SCHEDULER_add_now (&do_announce, NULL); | 1144 | GNUNET_SCHEDULER_add_now (&do_announce, NULL); |
1132 | } | 1145 | } |
1133 | 1146 | ||
@@ -1226,6 +1239,24 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1226 | char *hosts_file; | 1239 | char *hosts_file; |
1227 | char *strings_file; | 1240 | char *strings_file; |
1228 | 1241 | ||
1242 | /* Initialize peers */ | ||
1243 | peers = GNUNET_malloc (sizeof (struct RegexPeer) * num_peers); | ||
1244 | for (i = 0; i < num_peers; i++) | ||
1245 | { | ||
1246 | struct RegexPeer *peer = &peers[i]; | ||
1247 | peer->id = i; | ||
1248 | peer->policy_file = NULL; | ||
1249 | /* Do not start peers on hosts[0] (master controller) */ | ||
1250 | /* peer->host_handle = hosts[1 + (peer_cnt % (num_hosts -1))]; */ | ||
1251 | peer->dht_handle = NULL; | ||
1252 | peer->search_handle = NULL; | ||
1253 | peer->stats_handle = NULL; | ||
1254 | peer->stats_op_handle = NULL; | ||
1255 | peer->search_str = NULL; | ||
1256 | peer->search_str_matched = GNUNET_NO; | ||
1257 | } | ||
1258 | |||
1259 | /* Check config */ | ||
1229 | if (NULL == config) | 1260 | if (NULL == config) |
1230 | { | 1261 | { |
1231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1262 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1233,8 +1264,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1233 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1264 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1234 | return; | 1265 | return; |
1235 | } | 1266 | } |
1267 | cfg = GNUNET_CONFIGURATION_dup (config); | ||
1236 | if (GNUNET_OK != | 1268 | if (GNUNET_OK != |
1237 | GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", | 1269 | GNUNET_CONFIGURATION_get_value_string (cfg, "REGEXPROFILER", |
1238 | "REGEX_PREFIX", | 1270 | "REGEX_PREFIX", |
1239 | ®ex_prefix)) | 1271 | ®ex_prefix)) |
1240 | { | 1272 | { |
@@ -1243,7 +1275,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1243 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1275 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1244 | return; | 1276 | return; |
1245 | } | 1277 | } |
1278 | if (GNUNET_OK != | ||
1279 | GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER", | ||
1280 | "REANNOUNCE_PERIOD_MAX", | ||
1281 | &reannounce_period_max)) | ||
1282 | { | ||
1283 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1284 | "reannounce_period_max not given. Using 10 minutes.\n"); | ||
1285 | reannounce_period_max = | ||
1286 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); | ||
1287 | } | ||
1246 | 1288 | ||
1289 | /* Check arguments */ | ||
1247 | hosts_file = args[0]; | 1290 | hosts_file = args[0]; |
1248 | if (NULL == hosts_file) | 1291 | if (NULL == hosts_file) |
1249 | { | 1292 | { |
@@ -1258,21 +1301,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1258 | _("No policy directory specified on command line. Exiting.\n")); | 1301 | _("No policy directory specified on command line. Exiting.\n")); |
1259 | return; | 1302 | return; |
1260 | } | 1303 | } |
1261 | |||
1262 | |||
1263 | if ( (NULL != data_filename) && | ||
1264 | (NULL == (data_file = | ||
1265 | GNUNET_DISK_file_open (data_filename, | ||
1266 | GNUNET_DISK_OPEN_READWRITE | | ||
1267 | GNUNET_DISK_OPEN_TRUNCATE | | ||
1268 | GNUNET_DISK_OPEN_CREATE, | ||
1269 | GNUNET_DISK_PERM_USER_READ | | ||
1270 | GNUNET_DISK_PERM_USER_WRITE))) ) | ||
1271 | { | ||
1272 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
1273 | "open", | ||
1274 | data_filename); | ||
1275 | } | ||
1276 | if (GNUNET_YES != GNUNET_DISK_directory_test (policy_dir, GNUNET_YES)) | 1304 | if (GNUNET_YES != GNUNET_DISK_directory_test (policy_dir, GNUNET_YES)) |
1277 | { | 1305 | { |
1278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1280,6 +1308,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1280 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1308 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1281 | return; | 1309 | return; |
1282 | } | 1310 | } |
1311 | if (-1 == (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL))) | ||
1312 | { | ||
1313 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1314 | _("No files found in `%s'\n"), | ||
1315 | policy_dir); | ||
1316 | return; | ||
1317 | } | ||
1283 | strings_file = args[2]; | 1318 | strings_file = args[2]; |
1284 | if (GNUNET_YES != GNUNET_DISK_file_test (strings_file)) | 1319 | if (GNUNET_YES != GNUNET_DISK_file_test (strings_file)) |
1285 | { | 1320 | { |
@@ -1306,26 +1341,33 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1306 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 1341 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
1307 | return; | 1342 | return; |
1308 | } | 1343 | } |
1309 | cfg = GNUNET_CONFIGURATION_dup (config); | ||
1310 | if (GNUNET_OK != | ||
1311 | GNUNET_CONFIGURATION_get_value_time (cfg, "REGEXPROFILER", | ||
1312 | "REANNOUNCE_PERIOD_MAX", | ||
1313 | &reannounce_period_max)) | ||
1314 | { | ||
1315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1316 | "reannounce_period_max not given. Using 10 minutes.\n"); | ||
1317 | reannounce_period_max = | ||
1318 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10); | ||
1319 | } | ||
1320 | for (i = 0; i < num_search_strings; i++) | 1344 | for (i = 0; i < num_search_strings; i++) |
1321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1345 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1322 | "search string: %s\n", | 1346 | "search string: %s\n", |
1323 | search_strings[i]); | 1347 | search_strings[i]); |
1348 | |||
1349 | /* Check logfile */ | ||
1350 | if ( (NULL != data_filename) && | ||
1351 | (NULL == (data_file = | ||
1352 | GNUNET_DISK_file_open (data_filename, | ||
1353 | GNUNET_DISK_OPEN_READWRITE | | ||
1354 | GNUNET_DISK_OPEN_TRUNCATE | | ||
1355 | GNUNET_DISK_OPEN_CREATE, | ||
1356 | GNUNET_DISK_PERM_USER_READ | | ||
1357 | GNUNET_DISK_PERM_USER_WRITE))) ) | ||
1358 | { | ||
1359 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
1360 | "open", | ||
1361 | data_filename); | ||
1362 | return; | ||
1363 | } | ||
1364 | |||
1324 | event_mask = 0LL; | 1365 | event_mask = 0LL; |
1325 | /* event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | 1366 | /* event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); |
1326 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | 1367 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); |
1327 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); | 1368 | event_mask |= (1LL << GNUNET_TESTBED_ET_CONNECT); |
1328 | event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);*/ | 1369 | event_mask |= (1LL << GNUNET_TESTBED_ET_DISCONNECT);*/ |
1370 | prof_start_time = GNUNET_TIME_absolute_get (); | ||
1329 | GNUNET_TESTBED_run (args[0], | 1371 | GNUNET_TESTBED_run (args[0], |
1330 | cfg, | 1372 | cfg, |
1331 | num_peers, | 1373 | num_peers, |
@@ -1336,7 +1378,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1336 | NULL); /* test_master cls */ | 1378 | NULL); /* test_master cls */ |
1337 | abort_task = | 1379 | abort_task = |
1338 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1380 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1339 | (GNUNET_TIME_UNIT_SECONDS, 5), | 1381 | (GNUNET_TIME_UNIT_MINUTES, 5), |
1340 | &do_abort, | 1382 | &do_abort, |
1341 | (void*) __LINE__); | 1383 | (void*) __LINE__); |
1342 | } | 1384 | } |