GNUnet  0.10.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 628 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().

629 {
630  enabled =
632  "FS",
633  "CONTENT_PUSHING");
634  if (GNUNET_YES != enabled)
635  return;
636 
637  if (GNUNET_OK !=
639  "fs",
640  "MIN_MIGRATION_DELAY",
642  {
644  "fs",
645  "MIN_MIGRATION_DELAY",
646  _("time required, content pushing disabled"));
647  return;
648  }
650 }
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:78
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:208
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:80
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 657 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().

658 {
659  if (NULL != mig_task)
660  {
662  mig_task = NULL;
663  }
664  if (NULL != mig_qe)
665  {
667  mig_qe = NULL;
668  }
669  while (NULL != mig_head)
671  GNUNET_assert (0 == mig_size);
672 }
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:965
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 570 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().

571 {
572  struct MigrationReadyPeer *mrp;
573 
574  if (GNUNET_YES != enabled)
575  return;
576  for (mrp = peer_head; NULL != mrp; mrp = mrp->next)
577  if (mrp->peer == peer)
578  break;
579  if (NULL != mrp)
580  {
581  /* same peer added twice, must not happen */
582  GNUNET_break (0);
583  return;
584  }
585 
587  "Adding peer %s to list for pushing\n",
589 
590  mrp = GNUNET_new (struct MigrationReadyPeer);
591  mrp->peer = peer;
592  find_content (mrp);
594  peer_tail,
595  mrp);
596 }
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:80
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 606 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().

607 {
608  struct MigrationReadyPeer *pos;
609 
610  for (pos = peer_head; NULL != pos; pos = pos->next)
611  if (pos->peer == peer)
612  break;
613  if (NULL == pos)
614  return;
615  if (NULL != pos->env)
616  GNUNET_MQ_send_cancel (pos->env);
618  peer_tail,
619  pos);
620  GNUNET_free (pos);
621 }
#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: