GNUnet  0.11.x
Functions
gnunet-service-fs_push.h File Reference

support for pushing out content More...

#include "gnunet-service-fs.h"
Include dependency graph for gnunet-service-fs_push.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GSF_push_init_ (void)
 Setup the module. More...
 
void GSF_push_done_ (void)
 Shutdown the module. More...
 
void GSF_push_start_ (struct GSF_ConnectedPeer *peer)
 A peer connected to us or we are now again allowed to push content. More...
 
void GSF_push_stop_ (struct GSF_ConnectedPeer *peer)
 A peer disconnected from us or asked us to stop pushing content for a while. More...
 

Detailed Description

support for pushing out content

Author
Christian Grothoff

Definition in file gnunet-service-fs_push.h.

Function Documentation

◆ GSF_push_init_()

void GSF_push_init_ ( void  )

Setup the module.

Definition at line 630 of file gnunet-service-fs_push.c.

References _, consider_gathering(), enabled, GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log_config_invalid(), GNUNET_OK, GNUNET_YES, GSF_cfg, and min_migration_delay.

Referenced by run().

631 {
632  enabled =
634  "FS",
635  "CONTENT_PUSHING");
636  if (GNUNET_YES != enabled)
637  return;
638 
639  if (GNUNET_OK !=
641  "fs",
642  "MIN_MIGRATION_DELAY",
644  {
646  "fs",
647  "MIN_MIGRATION_DELAY",
648  _ ("time required, content pushing disabled"));
649  return;
650  }
652 }
int GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
static int enabled
Is this module enabled?
static struct GNUNET_TIME_Relative min_migration_delay
What is the maximum frequency at which we are allowed to poll the datastore for migration content...
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static void consider_gathering(void)
If the migration task is not currently running, consider (re)scheduling it with the appropriate delay...
#define GNUNET_YES
Definition: gnunet_common.h:77
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_push_done_()

void GSF_push_done_ ( void  )

Shutdown the module.

Definition at line 659 of file gnunet-service-fs_push.c.

References delete_migration_block(), GNUNET_assert, GNUNET_DATASTORE_cancel(), GNUNET_SCHEDULER_cancel(), and mig_size.

Referenced by shutdown_task().

660 {
661  if (NULL != mig_task)
662  {
664  mig_task = NULL;
665  }
666  if (NULL != mig_qe)
667  {
669  mig_qe = NULL;
670  }
671  while (NULL != mig_head)
673  GNUNET_assert (0 == mig_size);
674 }
static struct GNUNET_DATASTORE_QueueEntry * mig_qe
Request to datastore for migration (or NULL).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct MigrationReadyBlock * mig_head
Head of linked list of blocks that can be migrated.
static struct GNUNET_SCHEDULER_Task * mig_task
ID of task that collects blocks for migration.
static void delete_migration_block(struct MigrationReadyBlock *mb)
Delete the given migration block.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
static unsigned int mig_size
Size of the doubly-linked list of migration blocks.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_push_start_()

void GSF_push_start_ ( struct GSF_ConnectedPeer peer)

A peer connected to us or we are now again allowed to push content.

Start pushing content to this peer.

Parameters
peerhandle for the peer that connected

A peer connected to us or we are now again allowed to push content.

Start pushing content to this peer.

Parameters
peerhandle for the peer that connected

Definition at line 572 of file gnunet-service-fs_push.c.

References enabled, find_content(), GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_YES, GSF_connected_peer_get_identity2_(), MigrationReadyPeer::next, peer, and MigrationReadyPeer::peer.

Referenced by peer_respect_cb(), and revive_migration().

573 {
574  struct MigrationReadyPeer *mrp;
575 
576  if (GNUNET_YES != enabled)
577  return;
578  for (mrp = peer_head; NULL != mrp; mrp = mrp->next)
579  if (mrp->peer == peer)
580  break;
581  if (NULL != mrp)
582  {
583  /* same peer added twice, must not happen */
584  GNUNET_break (0);
585  return;
586  }
587 
589  "Adding peer %s to list for pushing\n",
591 
592  mrp = GNUNET_new (struct MigrationReadyPeer);
593  mrp->peer = peer;
594  find_content (mrp);
596  peer_tail,
597  mrp);
598 }
struct GSF_ConnectedPeer * peer
Handle to peer.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static struct MigrationReadyPeer * peer_tail
Tail of linked list of peers.
Information about a peer waiting for migratable data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int enabled
Is this module enabled?
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct MigrationReadyPeer * next
This is a doubly-linked list.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_(const struct GSF_ConnectedPeer *cp)
Obtain the identity of a connected peer.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
static void find_content(void *cls)
Find content for migration to this peer.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct MigrationReadyPeer * peer_head
Head of linked list of peers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_push_stop_()

void GSF_push_stop_ ( struct GSF_ConnectedPeer peer)

A peer disconnected from us or asked us to stop pushing content for a while.

Stop pushing content to this peer.

Parameters
peerhandle for the peer that disconnected

A peer disconnected from us or asked us to stop pushing content for a while.

Stop pushing content to this peer.

Parameters
peerhandle for the peer that disconnected

Definition at line 608 of file gnunet-service-fs_push.c.

References MigrationReadyPeer::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_send_cancel(), MigrationReadyPeer::next, and MigrationReadyPeer::peer.

Referenced by GSF_peer_disconnect_handler(), and handle_p2p_migration_stop().

609 {
610  struct MigrationReadyPeer *pos;
611 
612  for (pos = peer_head; NULL != pos; pos = pos->next)
613  if (pos->peer == peer)
614  break;
615  if (NULL == pos)
616  return;
617  if (NULL != pos->env)
618  GNUNET_MQ_send_cancel (pos->env);
620  peer_tail,
621  pos);
622  GNUNET_free (pos);
623 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GSF_ConnectedPeer * peer
Handle to peer.
struct GNUNET_MQ_Envelope * env
Envelope of the currently pushed message.
static struct MigrationReadyPeer * peer_tail
Tail of linked list of peers.
Information about a peer waiting for migratable data.
struct MigrationReadyPeer * next
This is a doubly-linked list.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
Definition: mq.c:916
static struct MigrationReadyPeer * peer_head
Head of linked list of peers.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: