- if (NULL != rc->topology_operation)
- {
- GNUNET_TESTBED_operation_done (rc->topology_operation);
- rc->topology_operation = NULL;
- }
- if (RC_INIT == rc->state)
- rc->state = RC_READY; /* Even though we haven't called the master callback */
- rc->peer_count = 0;
- /* Check if some peers are stopped */
- for (peer = 0; peer < rc->num_peers; peer++)
- {
- if (NULL == rc->peers[peer])
- continue;
- if (PS_STOPPED != rc->peers[peer]->state)
- break;
- }
- if (peer == rc->num_peers)
- {
- /* All peers are stopped */
- rc->state = RC_PEERS_STOPPED;
- all_peers_destroyed = GNUNET_YES;
- for (peer = 0; peer < rc->num_peers; peer++)
- {
- if (NULL == rc->peers[peer])
- continue;
- all_peers_destroyed = GNUNET_NO;
- dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
- dll_op->op = GNUNET_TESTBED_peer_destroy (rc->peers[peer]);
- GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
- dll_op);
- }
- if (all_peers_destroyed == GNUNET_NO)
- return;
- }
- /* Some peers are stopped */
- for (peer = 0; peer < rc->num_peers; peer++)
- {
- if ((NULL == rc->peers[peer]) || (PS_STARTED != rc->peers[peer]->state))
- {
- rc->peer_count++;
- continue;
- }
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer %u\n", peer);
- dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
- dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL);
- dll_op->cls = rc->peers[peer];
- GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail,
- dll_op);
- }
- if (rc->peer_count != rc->num_peers)
- return;