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 626 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().

627 {
628  enabled =
630  "FS",
631  "CONTENT_PUSHING");
632  if (GNUNET_YES != enabled)
633  return;
634 
635  if (GNUNET_OK !=
637  "fs",
638  "MIN_MIGRATION_DELAY",
640  {
642  "fs",
643  "MIN_MIGRATION_DELAY",
644  _("time required, content pushing disabled"));
645  return;
646  }
648 }
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 655 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().

656 {
657  if (NULL != mig_task)
658  {
660  mig_task = NULL;
661  }
662  if (NULL != mig_qe)
663  {
665  mig_qe = NULL;
666  }
667  while (NULL != mig_head)
669  GNUNET_assert(0 == mig_size);
670 }
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:956
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 568 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().

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

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