[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34632 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34632 - gnunet/src/fs |
Date: |
Tue, 16 Dec 2014 18:34:18 +0100 |
Author: grothoff
Date: 2014-12-16 18:34:18 +0100 (Tue, 16 Dec 2014)
New Revision: 34632
Modified:
gnunet/src/fs/fs_test_lib_data.conf
gnunet/src/fs/gnunet-service-fs.c
gnunet/src/fs/gnunet-service-fs_cp.c
gnunet/src/fs/gnunet-service-fs_cp.h
gnunet/src/fs/gnunet-service-fs_pr.c
gnunet/src/fs/gnunet-service-fs_push.c
Log:
do not poll empty database every 100ms for migration, doxygen fixes, code
cleanup
Modified: gnunet/src/fs/fs_test_lib_data.conf
===================================================================
--- gnunet/src/fs/fs_test_lib_data.conf 2014-12-15 18:58:47 UTC (rev 34631)
+++ gnunet/src/fs/fs_test_lib_data.conf 2014-12-16 17:34:18 UTC (rev 34632)
@@ -10,8 +10,8 @@
QUOTA = 2 GB
#PLUGIN = heap
#
-#[fs]
-#DELAY = YES
+[fs]
+FORCESTART = YES
[testbed]
OVERLAY_TOPOLOGY = CLIQUE
Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c 2014-12-15 18:58:47 UTC (rev 34631)
+++ gnunet/src/fs/gnunet-service-fs.c 2014-12-16 17:34:18 UTC (rev 34632)
@@ -220,9 +220,9 @@
* all.
*
* @param priority priority of the request (used as a reference point to
compare with the load)
- * @return GNUNET_YES if the load is too high to do anything (load high)
- * GNUNET_NO to process normally (load normal)
- * GNUNET_SYSERR to process for free (load low)
+ * @return #GNUNET_YES if the load is too high to do anything (load high)
+ * #GNUNET_NO to process normally (load normal)
+ * #GNUNET_SYSERR to process for free (load low)
*/
int
GSF_test_get_load_too_high_ (uint32_t priority)
@@ -248,7 +248,7 @@
* @param bandwidth_out assigned outbound bandwidth for the connection
* @param bandwidth_in assigned inbound bandwidth for the connection
* @param ats performance data for the address (as far as known)
- * @param ats_count number of performance records in 'ats'
+ * @param ats_count number of performance records in @a ats
*/
static void
update_latencies (void *cls,
@@ -306,6 +306,9 @@
{
struct GSF_ConnectedPeer *cp;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received P2P PUT from %s\n",
+ GNUNET_i2s (other));
cp = GSF_peer_get_ (other);
if (NULL == cp)
{
@@ -321,7 +324,7 @@
* We have a new request, consider forwarding it to the given
* peer.
*
- * @param cls the 'struct GSF_PendingRequest'
+ * @param cls the `struct GSF_PendingRequest`
* @param peer identity of the peer
* @param cp handle to the connected peer record
* @param ppd peer performance data
Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c 2014-12-15 18:58:47 UTC (rev
34631)
+++ gnunet/src/fs/gnunet-service-fs_cp.c 2014-12-16 17:34:18 UTC (rev
34632)
@@ -368,13 +368,15 @@
/**
* Core is ready to transmit to a peer, get the message.
*
- * @param cls the 'struct GSF_PeerTransmitHandle' of the message
+ * @param cls the `struct GSF_PeerTransmitHandle` of the message
* @param size number of bytes core is willing to take
* @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
*/
static size_t
-peer_transmit_ready_cb (void *cls, size_t size, void *buf);
+peer_transmit_ready_cb (void *cls,
+ size_t size,
+ void *buf);
/**
@@ -388,8 +390,10 @@
* long should the client wait until re-trying?
*/
static void
-ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
- int32_t amount, struct GNUNET_TIME_Relative res_delay);
+ats_reserve_callback (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ int32_t amount,
+ struct GNUNET_TIME_Relative res_delay);
/**
@@ -447,10 +451,10 @@
/**
* Core is ready to transmit to a peer, get the message.
*
- * @param cls the 'struct GSF_PeerTransmitHandle' of the message
+ * @param cls the `struct GSF_PeerTransmitHandle` of the message
* @param size number of bytes core is willing to take
* @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
*/
static size_t
peer_transmit_ready_cb (void *cls, size_t size, void *buf)
@@ -502,7 +506,7 @@
/**
* (re)try to reserve bandwidth from the given peer.
*
- * @param cls the 'struct GSF_ConnectedPeer' to reserve from
+ * @param cls the `struct GSF_ConnectedPeer` to reserve from
* @param tc scheduler context
*/
static void
@@ -564,6 +568,7 @@
}
}
+
/**
* Function called by PEERSTORE with peer respect record
*
@@ -573,7 +578,9 @@
* @return #GNUNET_NO to stop iterating since we only expect 0 or 1 records
*/
static int
-peer_respect_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg)
+peer_respect_cb (void *cls,
+ struct GNUNET_PEERSTORE_Record *record,
+ char *emsg)
{
struct GSF_ConnectedPeer *cp = cls;
@@ -631,11 +638,12 @@
* It may be time to re-start migrating content to this
* peer. Check, and if so, restart migration.
*
- * @param cls the 'struct GSF_ConnectedPeer'
+ * @param cls the `struct GSF_ConnectedPeer`
* @param tc scheduler context
*/
static void
-revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+revive_migration (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GSF_ConnectedPeer *cp = cls;
struct GNUNET_TIME_Relative bt;
@@ -675,8 +683,8 @@
* @param other the other peer involved (sender or receiver, NULL
* for loopback messages where we are both sender and receiver)
* @param message the actual message
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
int
GSF_handle_p2p_migration_stop_ (void *cls,
@@ -707,7 +715,8 @@
{
GSF_push_stop_ (cp);
cp->mig_revive_task =
- GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp);
+ GNUNET_SCHEDULER_add_delayed (bt,
+ &revive_migration, cp);
}
return GNUNET_OK;
}
@@ -716,8 +725,8 @@
/**
* Copy reply and free put message.
*
- * @param cls the 'struct PutMessage'
- * @param buf_size number of bytes available in buf
+ * @param cls the `struct PutMessage`
+ * @param buf_size number of bytes available in @a buf
* @param buf where to copy the message, NULL on error (peer disconnect)
* @return number of bytes copied to 'buf', can be 0 (without indicating an
error)
*/
@@ -779,11 +788,13 @@
*
* @param cls unused
* @param query hash code of the request
- * @param value the 'struct GSF_PendingRequest'
- * @return GNUNET_YES (continue to iterate)
+ * @param value the `struct GSF_PendingRequest`
+ * @return #GNUNET_YES (continue to iterate)
*/
static int
-cancel_pending_request (void *cls, const struct GNUNET_HashCode * query, void
*value)
+cancel_pending_request (void *cls,
+ const struct GNUNET_HashCode *query,
+ void *value)
{
struct PeerRequest *peerreq = value;
struct GSF_PendingRequest *pr = peerreq->pr;
@@ -803,7 +814,8 @@
* @param tc task context
*/
static void
-peer_request_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+peer_request_destroy (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerRequest *peerreq = cls;
struct GSF_PendingRequest *pr = peerreq->pr;
@@ -822,7 +834,8 @@
* @param tc scheduler context
*/
static void
-transmit_delayed_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+transmit_delayed_now (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GSF_DelayedHandle *dh = cls;
struct GSF_ConnectedPeer *cp = dh->cp;
@@ -873,22 +886,25 @@
* and will also not be called anymore after a call signalling
* expiration.
*
- * @param cls 'struct PeerRequest' this is an answer for
+ * @param cls `struct PeerRequest` this is an answer for
* @param eval evaluation of the result
* @param pr handle to the original pending request
* @param reply_anonymity_level anonymity level for the reply, UINT32_MAX for
"unknown"
- * @param expiration when does 'data' expire?
+ * @param expiration when does @a data expire?
* @param last_transmission when did we last transmit a request for this block
* @param type type of the block
* @param data response data, NULL on request expiration
- * @param data_len number of bytes in data
+ * @param data_len number of bytes in @a data
*/
static void
-handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
- struct GSF_PendingRequest *pr, uint32_t
reply_anonymity_level,
+handle_p2p_reply (void *cls,
+ enum GNUNET_BLOCK_EvaluationResult eval,
+ struct GSF_PendingRequest *pr,
+ uint32_t reply_anonymity_level,
struct GNUNET_TIME_Absolute expiration,
struct GNUNET_TIME_Absolute last_transmission,
- enum GNUNET_BLOCK_Type type, const void *data,
+ enum GNUNET_BLOCK_Type type,
+ const void *data,
size_t data_len)
{
struct PeerRequest *peerreq = cls;
@@ -1328,7 +1344,8 @@
* @param tc scheduler context
*/
static void
-peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc)
+peer_transmit_timeout (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GSF_PeerTransmitHandle *pth = cls;
struct GSF_ConnectedPeer *cp;
@@ -1369,9 +1386,12 @@
* @return handle to cancel request
*/
struct GSF_PeerTransmitHandle *
-GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query,
- uint32_t priority, struct GNUNET_TIME_Relative timeout,
- size_t size, GSF_GetMessageCallback gmc, void *gmc_cls)
+GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
+ int is_query,
+ uint32_t priority,
+ struct GNUNET_TIME_Relative timeout,
+ size_t size,
+ GSF_GetMessageCallback gmc, void *gmc_cls)
{
struct GSF_PeerTransmitHandle *pth;
struct GSF_PeerTransmitHandle *pos;
@@ -1500,7 +1520,8 @@
* @param peer identity of peer that connected
*/
void
-GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity
*peer)
+GSF_peer_disconnect_handler_ (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct GSF_ConnectedPeer *cp;
struct GSF_PeerTransmitHandle *pth;
@@ -1581,7 +1602,7 @@
/**
- * Closure for 'call_iterator'.
+ * Closure for #call_iterator().
*/
struct IterationContext
{
@@ -1591,7 +1612,7 @@
GSF_ConnectedPeerIterator it;
/**
- * Closure for 'it'.
+ * Closure for @e it.
*/
void *it_cls;
};
@@ -1606,12 +1627,16 @@
* @return #GNUNET_YES to continue iteration
*/
static int
-call_iterator (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
+call_iterator (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct IterationContext *ic = cls;
struct GSF_ConnectedPeer *cp = value;
- ic->it (ic->it_cls, (const struct GNUNET_PeerIdentity *) key, cp, &cp->ppd);
+ ic->it (ic->it_cls,
+ key, cp,
+ &cp->ppd);
return GNUNET_YES;
}
@@ -1623,13 +1648,16 @@
* @param it_cls closure for @a it
*/
void
-GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls)
+GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it,
+ void *it_cls)
{
struct IterationContext ic;
ic.it = it;
ic.it_cls = it_cls;
- GNUNET_CONTAINER_multipeermap_iterate (cp_map, &call_iterator, &ic);
+ GNUNET_CONTAINER_multipeermap_iterate (cp_map,
+ &call_iterator,
+ &ic);
}
@@ -1665,13 +1693,15 @@
/**
* Assemble a migration stop message for transmission.
*
- * @param cls the 'struct GSF_ConnectedPeer' to use
- * @param size number of bytes we're allowed to write to buf
+ * @param cls the `struct GSF_ConnectedPeer` to use
+ * @param size number of bytes we're allowed to write to @a buf
* @param buf where to copy the message
- * @return number of bytes copied to buf
+ * @return number of bytes copied to @a buf
*/
static size_t
-create_migration_stop_message (void *cls, size_t size, void *buf)
+create_migration_stop_message (void *cls,
+ size_t size,
+ void *buf)
{
struct GSF_ConnectedPeer *cp = cls;
struct MigrationStopMessage msm;
Modified: gnunet/src/fs/gnunet-service-fs_cp.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.h 2014-12-15 18:58:47 UTC (rev
34631)
+++ gnunet/src/fs/gnunet-service-fs_cp.h 2014-12-16 17:34:18 UTC (rev
34632)
@@ -158,23 +158,25 @@
* @param cp handle to the connected peer record
* @param perf peer performance data
*/
-typedef void (*GSF_ConnectedPeerIterator) (void *cls,
- const struct GNUNET_PeerIdentity *
- peer, struct GSF_ConnectedPeer * cp,
- const struct GSF_PeerPerformanceData
- * ppd);
+typedef void
+(*GSF_ConnectedPeerIterator) (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ struct GSF_ConnectedPeer *cp,
+ const struct GSF_PeerPerformanceData *ppd);
/**
* Function called to get a message for transmission.
*
* @param cls closure
- * @param buf_size number of bytes available in buf
+ * @param buf_size number of bytes available in @a buf
* @param buf where to copy the message, NULL on error (peer disconnect)
- * @return number of bytes copied to 'buf', can be 0 (without indicating an
error)
+ * @return number of bytes copied to @a buf, can be 0 (without indicating an
error)
*/
-typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size,
- void *buf);
+typedef size_t
+(*GSF_GetMessageCallback) (void *cls,
+ size_t buf_size,
+ void *buf);
/**
@@ -182,11 +184,12 @@
*
* @param cls closure
* @param cp handle to the connected peer record
- * @param success GNUNET_YES on success, GNUNET_NO on failure
+ * @param success #GNUNET_YES on success, #GNUNET_NO on failure
*/
-typedef void (*GSF_PeerReserveCallback) (void *cls,
- struct GSF_ConnectedPeer * cp,
- int success);
+typedef void
+(*GSF_PeerReserveCallback) (void *cls,
+ struct GSF_ConnectedPeer *cp,
+ int success);
/**
@@ -195,8 +198,9 @@
* @param cls closure
* @param cp handle to the newly created connected peer record
*/
-typedef void (*GSF_ConnectedPeerCreationCallback) (void *cls,
- struct GSF_ConnectedPeer
*cp);
+typedef void
+(*GSF_ConnectedPeerCreationCallback) (void *cls,
+ struct GSF_ConnectedPeer *cp);
/**
@@ -255,9 +259,12 @@
* @return handle to cancel request
*/
struct GSF_PeerTransmitHandle *
-GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query,
- uint32_t priority, struct GNUNET_TIME_Relative timeout,
- size_t size, GSF_GetMessageCallback gmc, void *gmc_cls);
+GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
+ int is_query,
+ uint32_t priority,
+ struct GNUNET_TIME_Relative timeout,
+ size_t size, GSF_GetMessageCallback gmc,
+ void *gmc_cls);
/**
@@ -314,8 +321,8 @@
* @param other the other peer involved (sender or receiver, NULL
* for loopback messages where we are both sender and receiver)
* @param message the actual message
- * @return GNUNET_OK to keep the connection open,
- * GNUNET_SYSERR to close it (signal serious error)
+ * @return #GNUNET_OK to keep the connection open,
+ * #GNUNET_SYSERR to close it (signal serious error)
*/
int
GSF_handle_p2p_migration_stop_ (void *cls,
Modified: gnunet/src/fs/gnunet-service-fs_pr.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.c 2014-12-15 18:58:47 UTC (rev
34631)
+++ gnunet/src/fs/gnunet-service-fs_pr.c 2014-12-16 17:34:18 UTC (rev
34632)
@@ -918,8 +918,8 @@
struct GNUNET_PeerIdentity origin;
/**
- * GNUNET_YES if we had a matching request for this block,
- * GNUNET_NO if not.
+ * #GNUNET_YES if we had a matching request for this block,
+ * #GNUNET_NO if not.
*/
int requested;
};
@@ -992,8 +992,10 @@
ppd->migration_delay = GNUNET_TIME_relative_multiply
(ppd->migration_delay, 2);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicated content already exists locally, asking to stop
migration for %s\n",
- GNUNET_STRINGS_relative_time_to_string (mig_pause,
GNUNET_YES));
- GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute
(mig_pause));
+ GNUNET_STRINGS_relative_time_to_string (mig_pause,
+ GNUNET_YES));
+ GSF_block_peer_migration_ (cp,
+ GNUNET_TIME_relative_to_absolute (mig_pause));
}
}
GNUNET_free (pmc);
@@ -1048,13 +1050,16 @@
* @param data pointer to the result data
*/
static void
-handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
+handle_dht_reply (void *cls,
+ struct GNUNET_TIME_Absolute exp,
+ const struct GNUNET_HashCode *key,
const struct GNUNET_PeerIdentity *get_path,
unsigned int get_path_length,
const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
+ unsigned int put_path_length,
+ enum GNUNET_BLOCK_Type type,
+ size_t size,
+ const void *data)
{
struct GSF_PendingRequest *pr = cls;
struct ProcessReplyClosure prq;
@@ -1089,7 +1094,10 @@
GNUNET_CONSTANTS_SERVICE_TIMEOUT,
&put_migration_continuation, pmc))
{
- put_migration_continuation (pmc, GNUNET_SYSERR,
GNUNET_TIME_UNIT_ZERO_ABS, NULL);
+ put_migration_continuation (pmc,
+ GNUNET_SYSERR,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ NULL);
}
}
}
@@ -1629,8 +1637,8 @@
* @param cp the other peer involved (sender or receiver, NULL
* for loopback messages where we are both sender and receiver)
* @param message the actual message
- * @return GNUNET_OK if the message was well-formed,
- * GNUNET_SYSERR if the message was malformed (close connection,
+ * @return #GNUNET_OK if the message was well-formed,
+ * #GNUNET_SYSERR if the message was malformed (close connection,
* do not cache under any circumstances)
*/
int
@@ -1661,10 +1669,14 @@
/* do not allow migrated content to live longer than 1 year */
expiration = GNUNET_TIME_absolute_min (GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_UNIT_YEARS),
expiration);
- if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
+ if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type)
return GNUNET_SYSERR;
if (GNUNET_OK !=
- GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query))
+ GNUNET_BLOCK_get_key (GSF_block_ctx,
+ type,
+ &put[1],
+ dsize,
+ &query))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
@@ -1681,7 +1693,9 @@
prq.priority = 0;
prq.anonymity_level = UINT32_MAX;
prq.request_found = GNUNET_NO;
- GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply,
+ GNUNET_CONTAINER_multihashmap_get_multiple (pr_map,
+ &query,
+ &process_reply,
&prq);
if (NULL != cp)
{
@@ -1696,7 +1710,8 @@
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Replicating result for query `%s' with priority %u\n",
- GNUNET_h2s (&query), prq.priority);
+ GNUNET_h2s (&query),
+ prq.priority);
pmc = GNUNET_new (struct PutMigrationContext);
pmc->start = GNUNET_TIME_absolute_get ();
pmc->requested = prq.request_found;
@@ -1711,7 +1726,10 @@
GNUNET_CONSTANTS_SERVICE_TIMEOUT,
&put_migration_continuation, pmc))
{
- put_migration_continuation (pmc, GNUNET_SYSERR,
GNUNET_TIME_UNIT_ZERO_ABS, NULL);
+ put_migration_continuation (pmc,
+ GNUNET_SYSERR,
+ GNUNET_TIME_UNIT_ZERO_ABS,
+ NULL);
}
}
else if (NULL != cp)
Modified: gnunet/src/fs/gnunet-service-fs_push.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_push.c 2014-12-15 18:58:47 UTC (rev
34631)
+++ gnunet/src/fs/gnunet-service-fs_push.c 2014-12-16 17:34:18 UTC (rev
34632)
@@ -181,7 +181,12 @@
*/
static int enabled;
+/**
+ * Did we find anything in the datastore?
+ */
+static int value_found;
+
/**
* Delete the given migration block.
*
@@ -205,16 +210,17 @@
/**
- * Transmit the message currently scheduled for
- * transmission.
+ * Transmit the message currently scheduled for transmission.
*
- * @param cls the 'struct MigrationReadyPeer'
- * @param buf_size number of bytes available in buf
+ * @param cls the `struct MigrationReadyPeer`
+ * @param buf_size number of bytes available in @a buf
* @param buf where to copy the message, NULL on error (peer disconnect)
- * @return number of bytes copied to 'buf', can be 0 (without indicating an
error)
+ * @return number of bytes copied to @a buf, can be 0 (without indicating an
error)
*/
static size_t
-transmit_message (void *cls, size_t buf_size, void *buf)
+transmit_message (void *cls,
+ size_t buf_size,
+ void *buf)
{
struct MigrationReadyPeer *peer = cls;
struct PutMessage *msg;
@@ -223,7 +229,7 @@
peer->th = NULL;
msg = peer->msg;
peer->msg = NULL;
- if (buf == NULL)
+ if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to migrate content to another peer (disconnect)\n");
@@ -234,8 +240,10 @@
GNUNET_assert (msize <= buf_size);
memcpy (buf, msg, msize);
GNUNET_free (msg);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pushing %u bytes to another peer\n",
- msize);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Pushing %u bytes to %s\n",
+ msize,
+ GNUNET_i2s (GSF_connected_peer_get_identity2_(peer->peer)));
find_content (peer);
return msize;
}
@@ -246,7 +254,7 @@
*
* @param peer target peer
* @param block the block
- * @return GNUNET_YES if the block was deleted (!)
+ * @return #GNUNET_YES if the block was deleted (!)
*/
static int
transmit_content (struct MigrationReadyPeer *peer,
@@ -287,9 +295,13 @@
ret = GNUNET_NO;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking for transmission of %u bytes for migration\n", msize);
- peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ ,
- GNUNET_TIME_UNIT_FOREVER_REL, msize,
+ "Asking for transmission of %u bytes to %s for migration\n",
+ msize,
+ GNUNET_i2s (GSF_connected_peer_get_identity2_(peer->peer)));
+ peer->th = GSF_peer_transmit_ (peer->peer,
+ GNUNET_NO, 0 /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ msize,
&transmit_message, peer);
return ret;
}
@@ -436,19 +448,27 @@
{
struct GNUNET_TIME_Relative delay;
- if (GSF_dsh == NULL)
+ if (NULL == GSF_dsh)
return;
- if (mig_qe != NULL)
+ if (NULL != mig_qe)
return;
- if (mig_task != GNUNET_SCHEDULER_NO_TASK)
+ if (GNUNET_SCHEDULER_NO_TASK != mig_task)
return;
if (mig_size >= MAX_MIGRATION_QUEUE)
return;
delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, mig_size);
delay = GNUNET_TIME_relative_divide (delay, MAX_MIGRATION_QUEUE);
delay = GNUNET_TIME_relative_max (delay, min_migration_delay);
+ if (GNUNET_NO == value_found)
+ {
+ /* wait at least 5s if the datastore is empty */
+ delay = GNUNET_TIME_relative_max (delay,
+ GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS,
+ 5));
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Scheduling gathering task (queue size: %u)\n", mig_size);
+ "Scheduling gathering task (queue size: %u)\n",
+ mig_size);
mig_task =
GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL);
}
@@ -469,21 +489,28 @@
* maybe 0 if no unique identifier is available
*/
static void
-process_migration_content (void *cls, const struct GNUNET_HashCode * key,
size_t size,
- const void *data, enum GNUNET_BLOCK_Type type,
- uint32_t priority, uint32_t anonymity,
- struct GNUNET_TIME_Absolute expiration, uint64_t
uid)
+process_migration_content (void *cls,
+ const struct GNUNET_HashCode *key,
+ size_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute expiration,
+ uint64_t uid)
{
struct MigrationReadyBlock *mb;
struct MigrationReadyPeer *pos;
mig_qe = NULL;
- if (key == NULL)
+ if (NULL == key)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No content found for
migration...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "No content found for migration...\n");
consider_gathering ();
return;
}
+ value_found = GNUNET_YES;
if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us <
MIN_MIGRATION_CONTENT_LIFETIME.rel_value_us)
{
@@ -494,34 +521,44 @@
if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
{
if (GNUNET_OK !=
- GNUNET_FS_handle_on_demand_block (key, size, data, type, priority,
- anonymity, expiration, uid,
+ GNUNET_FS_handle_on_demand_block (key,
+ size,
+ data,
+ type,
+ priority,
+ anonymity,
+ expiration,
+ uid,
&process_migration_content, NULL))
consider_gathering ();
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Retrieved block `%s' of type %u for migration (queue size:
%u/%u)\n",
- GNUNET_h2s (key), type, mig_size + 1, MAX_MIGRATION_QUEUE);
+ GNUNET_h2s (key),
+ type, mig_size + 1,
+ MAX_MIGRATION_QUEUE);
mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size);
mb->query = *key;
mb->expiration = expiration;
mb->size = size;
mb->type = type;
memcpy (&mb[1], data, size);
- GNUNET_CONTAINER_DLL_insert_after (mig_head, mig_tail, mig_tail, mb);
+ GNUNET_CONTAINER_DLL_insert_after (mig_head,
+ mig_tail,
+ mig_tail,
+ mb);
mig_size++;
- pos = peer_head;
- while (pos != NULL)
+ for (pos = peer_head; NULL != pos; pos = pos->next)
{
if (NULL == pos->th)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Preparing to push best content to peer\n");
+ "Preparing to push best content to peer %s\n",
+ GNUNET_i2s (GSF_connected_peer_get_identity2_(pos->peer)));
if (GNUNET_YES == transmit_content (pos, mb))
break; /* 'mb' was freed! */
}
- pos = pos->next;
}
consider_gathering ();
}
@@ -541,18 +578,18 @@
mig_task = GNUNET_SCHEDULER_NO_TASK;
if (mig_size >= MAX_MIGRATION_QUEUE)
return;
- if (GSF_dsh != NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking datastore for content for replication (queue size:
%u)\n",
- mig_size);
- mig_qe =
- GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &process_migration_content,
NULL);
- if (NULL == mig_qe)
- consider_gathering ();
- }
+ if (NULL == GSF_dsh)
+ return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Asking datastore for content for replication (queue size:
%u)\n",
+ mig_size);
+ value_found = GNUNET_NO;
+ mig_qe =
+ GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &process_migration_content, NULL);
+ if (NULL == mig_qe)
+ consider_gathering ();
}
@@ -569,10 +606,16 @@
if (GNUNET_YES != enabled)
return;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding peer %s to list for pushing\n",
+ GNUNET_i2s (GSF_connected_peer_get_identity2_(peer)));
+
mrp = GNUNET_new (struct MigrationReadyPeer);
mrp->peer = peer;
find_content (mrp);
- GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, mrp);
+ GNUNET_CONTAINER_DLL_insert (peer_head,
+ peer_tail,
+ mrp);
}
@@ -587,27 +630,25 @@
{
struct MigrationReadyPeer *pos;
- pos = peer_head;
- while (pos != NULL)
+ for (pos = peer_head; NULL != pos; pos = pos->next)
+ if (pos->peer == peer)
+ break;
+ if (NULL == pos)
+ return;
+ GNUNET_CONTAINER_DLL_remove (peer_head,
+ peer_tail,
+ pos);
+ if (NULL != pos->th)
{
- if (pos->peer == peer)
- {
- GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos);
- if (NULL != pos->th)
- {
- GSF_peer_transmit_cancel_ (pos->th);
- pos->th = NULL;
- }
- if (NULL != pos->msg)
- {
- GNUNET_free (pos->msg);
- pos->msg = NULL;
- }
- GNUNET_free (pos);
- return;
- }
- pos = pos->next;
+ GSF_peer_transmit_cancel_ (pos->th);
+ pos->th = NULL;
}
+ if (NULL != pos->msg)
+ {
+ GNUNET_free (pos->msg);
+ pos->msg = NULL;
+ }
+ GNUNET_free (pos);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34632 - gnunet/src/fs,
gnunet <=