diff options
Diffstat (limited to 'src/sensor/gnunet-sensor-profiler.c')
-rw-r--r-- | src/sensor/gnunet-sensor-profiler.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/src/sensor/gnunet-sensor-profiler.c b/src/sensor/gnunet-sensor-profiler.c index 21a96b7a3..848fdf9c6 100644 --- a/src/sensor/gnunet-sensor-profiler.c +++ b/src/sensor/gnunet-sensor-profiler.c | |||
@@ -55,11 +55,6 @@ struct PeerInfo | |||
55 | */ | 55 | */ |
56 | struct GNUNET_TESTBED_Peer *testbed_peer; | 56 | struct GNUNET_TESTBED_Peer *testbed_peer; |
57 | 57 | ||
58 | /** | ||
59 | * TESTBED operation connecting us to sensor service on this peer | ||
60 | */ | ||
61 | struct GNUNET_TESTBED_Operation *sensor_op; | ||
62 | |||
63 | }; | 58 | }; |
64 | 59 | ||
65 | 60 | ||
@@ -131,17 +126,7 @@ copy_dir (const char *src, const char *dst); | |||
131 | static void | 126 | static void |
132 | do_shutdown () // TODO: schedule timeout shutdown | 127 | do_shutdown () // TODO: schedule timeout shutdown |
133 | { | 128 | { |
134 | int i; | ||
135 | |||
136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n"); | 129 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down.\n"); |
137 | for (i = 0; i < num_peers; i++) | ||
138 | { | ||
139 | if (NULL != all_peers_info[i].sensor_op) | ||
140 | { | ||
141 | GNUNET_TESTBED_operation_done (all_peers_info[i].sensor_op); | ||
142 | all_peers_info[i].sensor_op = NULL; | ||
143 | } | ||
144 | } | ||
145 | if (NULL != peerstore_op) | 130 | if (NULL != peerstore_op) |
146 | { | 131 | { |
147 | GNUNET_TESTBED_operation_done (peerstore_op); | 132 | GNUNET_TESTBED_operation_done (peerstore_op); |
@@ -351,17 +336,16 @@ peerstore_disconnect_adapter (void *cls, void *op_result) | |||
351 | 336 | ||
352 | 337 | ||
353 | /** | 338 | /** |
354 | * Callback to be called when sensor service connect operation is completed | 339 | * Callback to be called when sensor service is started |
355 | * | 340 | * |
356 | * @param cls the callback closure from functions generating an operation | 341 | * @param cls the callback closure from functions generating an operation |
357 | * @param op the operation that has been finished | 342 | * @param op the operation that has been finished |
358 | * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter() | ||
359 | * @param emsg error message in case the operation has failed; will be NULL if | 343 | * @param emsg error message in case the operation has failed; will be NULL if |
360 | * operation has executed successfully. | 344 | * operation has executed successfully. |
361 | */ | 345 | */ |
362 | static void | 346 | static void |
363 | sensor_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | 347 | sensor_service_started (void *cls, struct GNUNET_TESTBED_Operation *op, |
364 | void *ca_result, const char *emsg) | 348 | const char *emsg) |
365 | { | 349 | { |
366 | struct PeerInfo *peer = cls; | 350 | struct PeerInfo *peer = cls; |
367 | 351 | ||
@@ -373,41 +357,7 @@ sensor_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer `%s'.\n", | 357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer `%s'.\n", |
374 | GNUNET_i2s (&peer->peer_id)); | 358 | GNUNET_i2s (&peer->peer_id)); |
375 | //TODO: | 359 | //TODO: |
376 | } | 360 | GNUNET_TESTBED_operation_done (op); |
377 | |||
378 | |||
379 | /** | ||
380 | * Adapter function called to establish a connection to sensor service. | ||
381 | * | ||
382 | * @param cls closure | ||
383 | * @param cfg configuration of the peer to connect to; will be available until | ||
384 | * GNUNET_TESTBED_operation_done() is called on the operation returned | ||
385 | * from GNUNET_TESTBED_service_connect() | ||
386 | * @return service handle to return in 'op_result', NULL on error | ||
387 | */ | ||
388 | static void * | ||
389 | sensor_connect_adapter (void *cls, | ||
390 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
391 | { | ||
392 | struct GNUNET_SENSOR_Handle *sensor; | ||
393 | |||
394 | sensor = GNUNET_SENSOR_connect (cfg); | ||
395 | return sensor; | ||
396 | } | ||
397 | |||
398 | |||
399 | /** | ||
400 | * Adapter function called to destroy a connection to sensor service. | ||
401 | * | ||
402 | * @param cls closure | ||
403 | * @param op_result service handle returned from the connect adapter | ||
404 | */ | ||
405 | static void | ||
406 | sensor_disconnect_adapter (void *cls, void *op_result) | ||
407 | { | ||
408 | struct GNUNET_SENSOR_Handle *sensor = op_result; | ||
409 | |||
410 | GNUNET_SENSOR_disconnect (sensor); | ||
411 | } | 361 | } |
412 | 362 | ||
413 | 363 | ||
@@ -445,11 +395,8 @@ peer_info_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op, | |||
445 | &dashboard_started, NULL, 1); | 395 | &dashboard_started, NULL, 1); |
446 | } | 396 | } |
447 | /* Start sensor service on every peer */ | 397 | /* Start sensor service on every peer */ |
448 | peer->sensor_op = | 398 | GNUNET_TESTBED_peer_manage_service (NULL, testbed_peer, "sensor", |
449 | GNUNET_TESTBED_service_connect (NULL, testbed_peer, "sensor", | 399 | &sensor_service_started, peer, 1); |
450 | &sensor_connect_cb, peer, | ||
451 | &sensor_connect_adapter, | ||
452 | &sensor_disconnect_adapter, NULL); | ||
453 | if (num_peers == peers_known) /* Last peer */ | 400 | if (num_peers == peers_known) /* Last peer */ |
454 | { | 401 | { |
455 | /* Connect to peerstore on first peer (collection point) */ | 402 | /* Connect to peerstore on first peer (collection point) */ |