[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15085 - gnunet/src/datastore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15085 - gnunet/src/datastore |
Date: |
Wed, 27 Apr 2011 21:04:31 +0200 |
Author: grothoff
Date: 2011-04-27 21:04:31 +0200 (Wed, 27 Apr 2011)
New Revision: 15085
Modified:
gnunet/src/datastore/datastore.h
gnunet/src/datastore/datastore_api.c
gnunet/src/datastore/gnunet-service-datastore.c
gnunet/src/datastore/plugin_datastore_sqlite.c
Log:
pass repl
Modified: gnunet/src/datastore/datastore.h
===================================================================
--- gnunet/src/datastore/datastore.h 2011-04-27 19:02:50 UTC (rev 15084)
+++ gnunet/src/datastore/datastore.h 2011-04-27 19:04:31 UTC (rev 15085)
@@ -220,6 +220,16 @@
uint32_t anonymity GNUNET_PACKED;
/**
+ * Desired replication level. 0 from service to API.
+ */
+ uint32_t replication GNUNET_PACKED;
+
+ /**
+ * For alignment.
+ */
+ uint32_t reserved GNUNET_PACKED;
+
+ /**
* Unique ID for the content (can be used for UPDATE);
* can be zero for remove (which indicates that
* the datastore should use whatever UID matches
Modified: gnunet/src/datastore/datastore_api.c
===================================================================
--- gnunet/src/datastore/datastore_api.c 2011-04-27 19:02:50 UTC (rev
15084)
+++ gnunet/src/datastore/datastore_api.c 2011-04-27 19:04:31 UTC (rev
15085)
@@ -854,9 +854,10 @@
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to put %u bytes of data under key `%s'\n",
+ "Asked to put %u bytes of data under key `%s' for %llu ms\n",
size,
- GNUNET_h2s (key));
+ GNUNET_h2s (key),
+ GNUNET_TIME_absolute_get_remaining (expiration).rel_value);
#endif
msize = sizeof(struct DataMessage) + size;
GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE);
@@ -885,6 +886,8 @@
dm->type = htonl(type);
dm->priority = htonl(priority);
dm->anonymity = htonl(anonymity);
+ dm->replication = htonl (replication);
+ dm->reserved = htonl (0);
dm->uid = GNUNET_htonll(0);
dm->expiration = GNUNET_TIME_absolute_hton(expiration);
dm->key = *key;
Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c 2011-04-27 19:02:50 UTC
(rev 15084)
+++ gnunet/src/datastore/gnunet-service-datastore.c 2011-04-27 19:04:31 UTC
(rev 15085)
@@ -646,16 +646,20 @@
dm->type = htonl(type);
dm->priority = htonl(priority);
dm->anonymity = htonl(anonymity);
+ dm->replication = htonl (0);
+ dm->reserved = htonl (0);
dm->expiration = GNUNET_TIME_absolute_hton(expiration);
dm->uid = GNUNET_htonll(uid);
dm->key = *key;
memcpy (&dm[1], data, size);
#if DEBUG_DATASTORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting `%s' message for `%s' of type %u\n",
+ "Transmitting `%s' message for `%s' of type %u with expiration
%llu (now: %llu)\n",
"DATA",
GNUNET_h2s (key),
- type);
+ type,
+ (unsigned long long) expiration.abs_value,
+ (unsigned long long) GNUNET_TIME_absolute_get ().abs_value);
#endif
GNUNET_STATISTICS_update (stats,
gettext_noop ("# results found"),
@@ -870,7 +874,7 @@
ntohl(dm->type),
ntohl(dm->priority),
ntohl(dm->anonymity),
- 0 /* FIXME: replication */,
+ ntohl(dm->replication),
GNUNET_TIME_absolute_ntoh(dm->expiration),
&msg);
if (GNUNET_OK == ret)
@@ -956,6 +960,15 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Result already present in datastore\n");
#endif
+ /* FIXME: change API to allow increasing 'replication' counter */
+ if ( (ntohl (dm->priority) > 0) ||
+ (GNUNET_TIME_absolute_ntoh(dm->expiration).abs_value >
+ expiration.abs_value) )
+ plugin->api->update (plugin->api->cls,
+ uid,
+ (int32_t) ntohl(dm->priority),
+ GNUNET_TIME_absolute_ntoh(dm->expiration),
+ NULL);
transmit_status (pc->client, GNUNET_NO, NULL);
GNUNET_SERVER_client_drop (pc->client);
GNUNET_free (pc);
Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c 2011-04-27 19:02:50 UTC
(rev 15084)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c 2011-04-27 19:04:31 UTC
(rev 15085)
@@ -31,7 +31,7 @@
/**
* Enable or disable logging debug messages.
*/
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
/**
* We allocate items on the stack at times. To prevent a stack
@@ -475,7 +475,7 @@
#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"sqlite",
- "Storing in database block with type %u/key `%s'/priority
%u/expiration %llu (%lld).\n",
+ "Storing in database block with type %u/key `%s'/priority
%u/expiration in %llu ms (%lld).\n",
type,
GNUNET_h2s(key),
priority,
@@ -650,6 +650,12 @@
break;
}
expiration.abs_value = sqlite3_column_int64 (stmt, 3);
+#if DEBUG_SQLITE
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+ "sqlite",
+ "Found reply in database with expiration %llu\n",
+ (unsigned long long) expiration.abs_value);
+#endif
ret = proc (proc_cls,
sqlite3_column_blob (stmt, 4) /* key */,
size,
@@ -1175,7 +1181,7 @@
#if DEBUG_SQLITE
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"sqlite",
- "sqlite plugin is finished doneing\n");
+ "sqlite plugin is finished\n");
#endif
return NULL;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15085 - gnunet/src/datastore,
gnunet <=