本文整理汇总了C++中GNUNET_SCHEDULER_shutdown函数的典型用法代码示例。如果您正苦于以下问题:C++ GNUNET_SCHEDULER_shutdown函数的具体用法?C++ GNUNET_SCHEDULER_shutdown怎么用?C++ GNUNET_SCHEDULER_shutdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GNUNET_SCHEDULER_shutdown函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_channel
/**
* Call MESH's monitor API, get info of one connection.
*
* @param cls Closure (unused).
* @param tc TaskContext
*/
static void
create_channel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_PeerIdentity pid;
enum GNUNET_MESH_ChannelOption opt;
GNUNET_assert (NULL == ch);
if (GNUNET_OK !=
GNUNET_CRYPTO_eddsa_public_key_from_string (target_id,
strlen (target_id),
&pid.public_key))
{
FPRINTF (stderr,
_("Invalid target `%s'\n"),
target_id);
GNUNET_SCHEDULER_shutdown ();
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to `%s'\n", target_id);
opt = GNUNET_MESH_OPTION_DEFAULT | GNUNET_MESH_OPTION_RELIABLE;
ch = GNUNET_MESH_channel_create (mh, NULL, &pid, target_port, opt);
if (GNUNET_NO == echo)
listen_stdio ();
else
GNUNET_SCHEDULER_add_now (send_echo, NULL);
}
示例2: data_ready
/**
* Function called to notify a client about the connection
* begin ready to queue more data. "buf" will be
* NULL and "size" zero if the connection was closed for
* writing in the meantime.
*
* FIXME
*
* @param cls closure
* @param size number of bytes available in buf
* @param buf where the callee should write the message
* @return number of bytes written to buf
*/
size_t
data_ready (void *cls, size_t size, void *buf)
{
struct GNUNET_MessageHeader *msg;
size_t total_size;
if (NULL == buf || 0 == size)
{
GNUNET_SCHEDULER_shutdown();
return 0;
}
total_size = data_size + sizeof (struct GNUNET_MessageHeader);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending %u bytes\n", data_size);
GNUNET_assert (size >= total_size);
msg = buf;
msg->size = htons (total_size);
msg->type = htons (GNUNET_MESSAGE_TYPE_MESH_CLI);
memcpy (&msg[1], cls, data_size);
if (GNUNET_NO == echo)
{
listen_stdio ();
}
else
{
echo_time = GNUNET_TIME_absolute_get ();
}
return total_size;
}
示例3: tunnel_callback
/**
* Method called to retrieve information about a specific tunnel the mesh peer
* has established, o`r is trying to establish.
*
* @param cls Closure.
* @param peer Peer towards whom the tunnel is directed.
* @param n_channels Number of channels.
* @param n_connections Number of connections.
* @param channels Channels.
* @param connections Connections.
* @param estate Encryption status.
* @param cstate Connectivity status.
*/
void
tunnel_callback (void *cls,
const struct GNUNET_PeerIdentity *peer,
unsigned int n_channels,
unsigned int n_connections,
uint32_t *channels,
struct GNUNET_HashCode *connections,
unsigned int estate,
unsigned int cstate)
{
unsigned int i;
if (NULL != peer)
{
FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
FPRINTF (stdout, "- %u channels\n", n_channels);
for (i = 0; i < n_channels; i++)
FPRINTF (stdout, " %u\n", channels[i]);
FPRINTF (stdout, "- %u connections\n", n_connections);
for (i = 0; i < n_connections; i++)
FPRINTF (stdout, " %s\n", GNUNET_h2s_full (&connections[i]));
FPRINTF (stdout, "- enc state: %u\n", estate);
FPRINTF (stdout, "- con state: %u\n", cstate);
}
if (GNUNET_YES != monitor_connections)
{
GNUNET_SCHEDULER_shutdown();
}
return;
}
示例4: topology_completed
static void
topology_completed (void *cls,
unsigned int nsuccess,
unsigned int nfailures)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Links successful %u / %u failed\n",
nsuccess,
nfailures);
GNUNET_TESTBED_operation_done (topology_op);
topology_op = NULL;
if (nfailures > 0)
{
fprintf (stderr,
"Error: links successful %u but %u failed\n",
nsuccess,
nfailures);
ok = 1;
}
else
ok = 0;
GNUNET_SCHEDULER_shutdown ();
}
示例5: do_shutdown
/**
* Shutdown nicely
*
* @param cls NULL
* @param tc the task context
*/
static void
do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct DLLOperation *dll_op;
unsigned int nhost;
shutdown_task = GNUNET_SCHEDULER_NO_TASK;
if (GNUNET_SCHEDULER_NO_TASK != abort_task)
GNUNET_SCHEDULER_cancel (abort_task);
if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task)
GNUNET_SCHEDULER_cancel (register_hosts_task);
if (NULL != reg_handle)
GNUNET_TESTBED_cancel_registration (reg_handle);
if (NULL != topology_op)
GNUNET_TESTBED_operation_done (topology_op);
for (nhost = 0; nhost < num_hosts; nhost++)
if (NULL != hosts[nhost])
GNUNET_TESTBED_host_destroy (hosts[nhost]);
GNUNET_free_non_null (hosts);
while (NULL != (dll_op = dll_op_head))
{
GNUNET_TESTBED_operation_done (dll_op->op);
GNUNET_CONTAINER_DLL_remove (dll_op_head, dll_op_tail, dll_op);
GNUNET_free (dll_op);
}
if (NULL != mc)
GNUNET_TESTBED_controller_disconnect (mc);
if (NULL != mc_proc)
GNUNET_TESTBED_controller_stop (mc_proc);
if (NULL != cfg)
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_SCHEDULER_shutdown (); /* Stop scheduler to shutdown testbed run */
}
示例6: allocation_cb
/**
* Callback invoked from the VPN service once a redirection is
* available. Provides the IP address that can now be used to
* reach the requested destination.
*
* @param cls closure
* @param af address family, AF_INET or AF_INET6; AF_UNSPEC on error;
* will match 'result_af' from the request
* @param address IP address (struct in_addr or struct in_addr6, depending on 'af')
* that the VPN allocated for the redirection;
* traffic to this IP will now be redirected to the
* specified target peer; NULL on error
*/
static void
allocation_cb (void *cls,
int af,
const void *address)
{
char buf[INET6_ADDRSTRLEN];
request = NULL;
switch (af)
{
case AF_INET6:
case AF_INET:
FPRINTF (stdout,
"%s\n",
inet_ntop (af, address, buf, sizeof (buf)));
break;
case AF_UNSPEC:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Error creating tunnel\n"));
ret = 1;
break;
default:
break;
}
GNUNET_SCHEDULER_shutdown ();
}
示例7: peer_create_cb
/**
* Functions of this signature are called when a peer has been successfully
* created
*
* @param cls the closure from GNUNET_TESTBED_peer_create()
* @param peer the handle for the created peer; NULL on any error during
* creation
* @param emsg NULL if peer is not NULL; else MAY contain the error description
*/
static void
peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
{
struct RunContextOperation *rcop = cls;
struct GNUNET_TESTBED_RunHandle *rc;
GNUNET_assert (NULL != rcop);
GNUNET_assert (NULL != (rc = rcop->rc));
remove_rcop (rc, rcop);
GNUNET_TESTBED_operation_done (rcop->op);
GNUNET_free (rcop);
if (NULL == peer)
{
if (NULL != emsg)
LOG (GNUNET_ERROR_TYPE_ERROR, "Error while creating a peer: %s\n",
emsg);
GNUNET_SCHEDULER_shutdown ();
return;
}
rc->peers[rc->peer_count] = peer;
rc->peer_count++;
if (rc->peer_count < rc->num_peers)
return;
DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc));
rc->state = RC_PEERS_CREATED;
GNUNET_SCHEDULER_add_now (&start_peers_task, rc);
}
示例8: do_download
static void
do_download (void *cls,
const char *emsg)
{
struct DownloadContext *dc = cls;
struct GNUNET_FS_Uri *uri = dc->uri;
GNUNET_TESTBED_operation_done (op);
op = NULL;
if (NULL != dc->fn)
{
GNUNET_DISK_directory_remove (dc->fn);
GNUNET_free (dc->fn);
}
GNUNET_free (dc);
if (NULL != emsg)
{
GNUNET_SCHEDULER_shutdown ();
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to stop source daemon: %s\n",
emsg);
GNUNET_FS_uri_destroy (uri);
ok = 1;
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Downloading %llu bytes\n",
(unsigned long long) FILESIZE);
start_time = GNUNET_TIME_absolute_get ();
GNUNET_FS_TEST_download (daemons[0], TIMEOUT, 1, SEED, uri, VERBOSE, &do_stop,
NULL);
GNUNET_FS_uri_destroy (uri);
}
示例9: cleanup_task
/**
* Task run during shutdown.
*
* @param cls unused
* @param tc unused
*/
static void
cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct ClientPeerContext *cp;
cp = cp_head;
while (NULL != cp)
{
GNUNET_CONTAINER_DLL_remove (cp_head, cp_tail, cp);
destroy_clientpeer (cp);
cp = cp_head;
}
if (NULL != cadet)
{
GNUNET_CADET_disconnect (cadet);
cadet = NULL;
}
if (NULL != peerstore)
{
GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES);
peerstore = NULL;
}
GNUNET_SENSOR_destroy_sensors (sensors);
if (NULL != sensor_dir)
{
GNUNET_free (sensor_dir);
sensor_dir = NULL;
}
GNUNET_SCHEDULER_shutdown ();
}
示例10: handle_shutdown
/**
* Handler for SHUTDOWN message.
*
* @param cls closure (refers to service)
* @param client identification of the client
* @param message the actual message
*/
static void
handle_shutdown (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
GNUNET_SCHEDULER_shutdown ();
GNUNET_SERVER_client_persist_ (client);
}
示例11: clean_up
static void
clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (p1.th != NULL)
{
if (p1.ghh != NULL)
{
GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
p1.ghh = NULL;
}
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
}
if (p2.th != NULL)
{
if (p2.ghh != NULL)
{
GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
p2.ghh = NULL;
}
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
}
GNUNET_SCHEDULER_shutdown ();
}
示例12: mesh_connect_cb
/**
* Callback to be called when a service connect operation is completed.
*
* @param cls The callback closure from functions generating an operation.
* @param op The operation that has been finished.
* @param ca_result The service handle returned from
* GNUNET_TESTBED_ConnectAdapter() (mesh handle).
* @param emsg Error message in case the operation has failed.
* NULL if operation has executed successfully.
*/
static void
mesh_connect_cb (void *cls,
struct GNUNET_TESTBED_Operation *op,
void *ca_result,
const char *emsg)
{
struct GNUNET_MESH_TEST_Context *ctx = cls;
unsigned int i;
if (NULL != emsg)
{
fprintf (stderr, "Failed to connect to MESH service: %s\n",
emsg);
GNUNET_SCHEDULER_shutdown ();
return;
}
for (i = 0; i < ctx->num_peers; i++)
if (op == ctx->ops[i])
ctx->meshes[i] = ca_result;
for (i = 0; i < ctx->num_peers; i++)
if (NULL == ctx->meshes[i])
return; /* still some MESH connections missing */
/* all MESH connections ready! */
ctx->app_main (ctx->app_main_cls,
ctx,
ctx->num_peers,
ctx->peers,
ctx->meshes);
}
示例13: identity_cb
/**
* Callback invoked from identity service with ego information.
* An @a ego of NULL means the ego was not found.
*
* @param cls closure with the configuration
* @param ego an ego known to identity service, or NULL
*/
static void
identity_cb (void *cls,
const struct GNUNET_IDENTITY_Ego *ego)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
el = NULL;
if (NULL == ego)
{
if (NULL != ego_name)
{
fprintf (stderr,
_("Ego `%s' not known to identity service\n"),
ego_name);
}
GNUNET_SCHEDULER_shutdown ();
ret = -1;
return;
}
zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
GNUNET_free_non_null (ego_name);
ego_name = NULL;
GNUNET_CLIENT_service_test ("namestore", cfg,
GNUNET_TIME_UNIT_SECONDS,
&testservice_task,
(void *) cfg);
}
示例14: testservice_id_task
static void
testservice_id_task (void *cls, int result)
{
const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
if (result != GNUNET_YES)
{
fprintf (stderr,
_("Identity service is not running\n"));
GNUNET_SCHEDULER_shutdown ();
ret = -1;
return;
}
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
&do_shutdown, (void *) cfg);
if (NULL == ego_name)
{
idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg);
if (NULL == idh)
fprintf (stderr, _("Cannot connect to identity service\n"));
ret = -1;
return;
}
el = GNUNET_IDENTITY_ego_lookup (cfg,
ego_name,
&identity_cb,
(void *) cfg);
}
示例15: GCD_init
/**
* Initialize the DHT subsystem.
*
* @param c Configuration.
*/
void
GCD_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "init\n");
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (c, "CADET",
"DHT_REPLICATION_LEVEL",
&dht_replication_level))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, "CADET",
"DHT_REPLICATION_LEVEL", "USING DEFAULT");
dht_replication_level = 3;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (c, "CADET", "ID_ANNOUNCE_TIME",
&id_announce_time))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, "CADET",
"ID_ANNOUNCE_TIME", "MISSING");
GNUNET_SCHEDULER_shutdown ();
return;
}
dht_handle = GNUNET_DHT_connect (c, 64);
if (NULL == dht_handle)
{
GNUNET_break (0);
}
announce_delay = GNUNET_TIME_UNIT_SECONDS;
announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, NULL);
get_requests = GNUNET_CONTAINER_multihashmap32_create (32);
}