* Note that the overall struct should end at a
* multiple of 64 bits.
*/
- int32_t was_transmitted;
+ int was_transmitted;
+
+ /**
+ * Are we expecting a single message in response to this
+ * request (and, if it is data, no 'END' message)?
+ */
+ int one_shot;
};
do_disconnect (h);
return;
}
- GNUNET_DATASTORE_iterate_get_next (h);
+ if (GNUNET_YES == qe->one_shot)
+ free_queue_entry (qe);
+ else
+ GNUNET_DATASTORE_iterate_get_next (h);
return;
}
dm = (const struct DataMessage*) msg;
ntohl(dm->anonymity),
GNUNET_TIME_absolute_ntoh(dm->expiration),
GNUNET_ntohll(dm->uid));
+ if (GNUNET_YES == qe->one_shot)
+ free_queue_entry (qe);
}
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to get random entry in %llu ms\n",
+ "Asked to get replication entry in %llu ms\n",
(unsigned long long) timeout.rel_value);
#endif
qc.rc.iter = iter;
{
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Could not create queue entry for GET RANDOM\n");
+ "Could not create queue entry for GET REPLICATION\n");
#endif
return NULL;
}
+ qe->one_shot = GNUNET_YES;
GNUNET_STATISTICS_update (h->stats,
- gettext_noop ("# GET RANDOM requests executed"),
+ gettext_noop ("# GET REPLICATION requests executed"),
1,
GNUNET_NO);
m = (struct GNUNET_MessageHeader*) &qe[1];
- m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM);
+ m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION);
m->size = htons(sizeof (struct GNUNET_MessageHeader));
process_queue (h);
return qe;
struct GetZeroAnonymityMessage *m;
union QueueContext qc;
+ GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Asked to get zero-anonymity entry in %llu ms\n",
/**
- * Handle GET_RANDOM-message.
+ * Handle GET_REPLICATION-message.
*
* @param cls closure
* @param client identification of the client
* @param message the actual message
*/
static void
-handle_get_random (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message)
+handle_get_replication (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
{
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request\n",
- "GET_RANDOM");
+ "GET_REPLICATION");
#endif
GNUNET_STATISTICS_update (stats,
- gettext_noop ("# GET RANDOM requests received"),
+ gettext_noop ("# GET REPLICATION requests received"),
1,
GNUNET_NO);
GNUNET_SERVER_client_keep (client);
enum GNUNET_BLOCK_Type type;
type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
+ if (type == GNUNET_BLOCK_TYPE_ANY)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Processing `%s' request\n",
{&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
sizeof (struct UpdateMessage) },
{&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 },
- {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM,
+ {&handle_get_replication, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
sizeof(struct GNUNET_MessageHeader) },
{&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
sizeof(struct GetZeroAnonymityMessage) },
sqlite3_stmt *stmt_2;
char *q;
+ GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
now = GNUNET_TIME_absolute_get ();
GNUNET_asprintf (&q,
"SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 "
- "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND hash < ?2) "
+ "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND type=%d AND hash < ?2) "
"ORDER BY hash DESC LIMIT 1",
- (unsigned long long) now.abs_value);
+ (unsigned long long) now.abs_value,
+ type);
if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK)
{
LOG_SQLITE (plugin, NULL,
GNUNET_free (q);
GNUNET_asprintf (&q,
"SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 "
- "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0) "
+ "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0 AND type=%d) "
"ORDER BY prio DESC, hash DESC LIMIT 1",
- (unsigned long long) now.abs_value);
+ (unsigned long long) now.abs_value,
+ type);
if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK)
{
LOG_SQLITE (plugin, NULL,
*
* @param cls closure
* @param type entries of which type should be considered?
- * Use 0 for any type.
+ * Myst not be zero (ANY).
* @param iter function to call on each matching value; however,
* after the first call to "iter", the plugin must wait
* until "NextRequest" was called before giving the iterator
*/
PluginPut put;
+ /**
+ * Update the priority for a particular key in the datastore. If
+ * the expiration time in value is different than the time found in
+ * the datastore, the higher value should be kept. For the
+ * anonymity level, the lower value is to be used. The specified
+ * priority should be added to the existing priority, ignoring the
+ * priority in value.
+ */
+ PluginUpdate update;
+
/**
* Function called by iterators whenever they want the next value;
* note that unlike all of the other callbacks, this one does get a
*/
PluginGet get;
+ /**
+ * Iterate over content with anonymity level zero.
+ */
+ PluginSelector iter_zero_anonymity;
+
/**
* Function to get a random item with high replication score from
* the database, lowering the item's replication score. Returns a
*/
PluginRandomGet expiration_get;
- /**
- * Update the priority for a particular key in the datastore. If
- * the expiration time in value is different than the time found in
- * the datastore, the higher value should be kept. For the
- * anonymity level, the lower value is to be used. The specified
- * priority should be added to the existing priority, ignoring the
- * priority in value.
- */
- PluginUpdate update;
-
- /**
- * Iterate over content with anonymity level zero.
- */
- PluginSelector iter_zero_anonymity;
-
/**
* Delete the database. The next operation is
* guaranteed to be unloading of the module.
* @param max_queue_size at what queue size should this request be dropped
* (if other requests of higher priority are in the queue)
* @param timeout how long to wait at most for a response
- * @param type allowed type for the operation (ANY for 'all types')
+ * @param type allowed type for the operation (never zero)
* @param iter function to call on a random value; it
* will be called once with a value (if available)
* and always once with a value of NULL at the end.
/**
* Message sent by datastore client to get random data.
*/
-#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM 98
+#define GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION 98
/**
* Message sent by datastore client to get random data.