aboutsummaryrefslogtreecommitdiff
path: root/src/datastore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-04-04 17:57:21 +0000
committerChristian Grothoff <christian@grothoff.org>2011-04-04 17:57:21 +0000
commit2663c23e2b0944dfb015332f10ff65cfc802588a (patch)
treec44540741af69049b6f1f0f7ea1dd574214d5c3c /src/datastore
parent060e3c202b9c4aed542617ac84b6b3061f51be2b (diff)
downloadgnunet-2663c23e2b0944dfb015332f10ff65cfc802588a.tar.gz
gnunet-2663c23e2b0944dfb015332f10ff65cfc802588a.zip
renaming, fixes
Diffstat (limited to 'src/datastore')
-rw-r--r--src/datastore/datastore_api.c25
-rw-r--r--src/datastore/gnunet-service-datastore.c20
-rw-r--r--src/datastore/plugin_datastore_sqlite.c11
3 files changed, 39 insertions, 17 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index dde45f24f..f6b5cd609 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -166,7 +166,13 @@ struct GNUNET_DATASTORE_QueueEntry
166 * Note that the overall struct should end at a 166 * Note that the overall struct should end at a
167 * multiple of 64 bits. 167 * multiple of 64 bits.
168 */ 168 */
169 int32_t was_transmitted; 169 int was_transmitted;
170
171 /**
172 * Are we expecting a single message in response to this
173 * request (and, if it is data, no 'END' message)?
174 */
175 int one_shot;
170 176
171}; 177};
172 178
@@ -1251,7 +1257,10 @@ process_result_message (void *cls,
1251 do_disconnect (h); 1257 do_disconnect (h);
1252 return; 1258 return;
1253 } 1259 }
1254 GNUNET_DATASTORE_iterate_get_next (h); 1260 if (GNUNET_YES == qe->one_shot)
1261 free_queue_entry (qe);
1262 else
1263 GNUNET_DATASTORE_iterate_get_next (h);
1255 return; 1264 return;
1256 } 1265 }
1257 dm = (const struct DataMessage*) msg; 1266 dm = (const struct DataMessage*) msg;
@@ -1273,6 +1282,8 @@ process_result_message (void *cls,
1273 ntohl(dm->anonymity), 1282 ntohl(dm->anonymity),
1274 GNUNET_TIME_absolute_ntoh(dm->expiration), 1283 GNUNET_TIME_absolute_ntoh(dm->expiration),
1275 GNUNET_ntohll(dm->uid)); 1284 GNUNET_ntohll(dm->uid));
1285 if (GNUNET_YES == qe->one_shot)
1286 free_queue_entry (qe);
1276} 1287}
1277 1288
1278 1289
@@ -1310,7 +1321,7 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
1310 1321
1311#if DEBUG_DATASTORE 1322#if DEBUG_DATASTORE
1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1313 "Asked to get random entry in %llu ms\n", 1324 "Asked to get replication entry in %llu ms\n",
1314 (unsigned long long) timeout.rel_value); 1325 (unsigned long long) timeout.rel_value);
1315#endif 1326#endif
1316 qc.rc.iter = iter; 1327 qc.rc.iter = iter;
@@ -1322,16 +1333,17 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
1322 { 1333 {
1323#if DEBUG_DATASTORE 1334#if DEBUG_DATASTORE
1324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1325 "Could not create queue entry for GET RANDOM\n"); 1336 "Could not create queue entry for GET REPLICATION\n");
1326#endif 1337#endif
1327 return NULL; 1338 return NULL;
1328 } 1339 }
1340 qe->one_shot = GNUNET_YES;
1329 GNUNET_STATISTICS_update (h->stats, 1341 GNUNET_STATISTICS_update (h->stats,
1330 gettext_noop ("# GET RANDOM requests executed"), 1342 gettext_noop ("# GET REPLICATION requests executed"),
1331 1, 1343 1,
1332 GNUNET_NO); 1344 GNUNET_NO);
1333 m = (struct GNUNET_MessageHeader*) &qe[1]; 1345 m = (struct GNUNET_MessageHeader*) &qe[1];
1334 m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM); 1346 m->type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION);
1335 m->size = htons(sizeof (struct GNUNET_MessageHeader)); 1347 m->size = htons(sizeof (struct GNUNET_MessageHeader));
1336 process_queue (h); 1348 process_queue (h);
1337 return qe; 1349 return qe;
@@ -1368,6 +1380,7 @@ GNUNET_DATASTORE_iterate_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
1368 struct GetZeroAnonymityMessage *m; 1380 struct GetZeroAnonymityMessage *m;
1369 union QueueContext qc; 1381 union QueueContext qc;
1370 1382
1383 GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
1371#if DEBUG_DATASTORE 1384#if DEBUG_DATASTORE
1372 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1373 "Asked to get zero-anonymity entry in %llu ms\n", 1386 "Asked to get zero-anonymity entry in %llu ms\n",
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 1d092a619..ba9bc5b93 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -1240,24 +1240,24 @@ handle_update (void *cls,
1240 1240
1241 1241
1242/** 1242/**
1243 * Handle GET_RANDOM-message. 1243 * Handle GET_REPLICATION-message.
1244 * 1244 *
1245 * @param cls closure 1245 * @param cls closure
1246 * @param client identification of the client 1246 * @param client identification of the client
1247 * @param message the actual message 1247 * @param message the actual message
1248 */ 1248 */
1249static void 1249static void
1250handle_get_random (void *cls, 1250handle_get_replication (void *cls,
1251 struct GNUNET_SERVER_Client *client, 1251 struct GNUNET_SERVER_Client *client,
1252 const struct GNUNET_MessageHeader *message) 1252 const struct GNUNET_MessageHeader *message)
1253{ 1253{
1254#if DEBUG_DATASTORE 1254#if DEBUG_DATASTORE
1255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1255 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1256 "Processing `%s' request\n", 1256 "Processing `%s' request\n",
1257 "GET_RANDOM"); 1257 "GET_REPLICATION");
1258#endif 1258#endif
1259 GNUNET_STATISTICS_update (stats, 1259 GNUNET_STATISTICS_update (stats,
1260 gettext_noop ("# GET RANDOM requests received"), 1260 gettext_noop ("# GET REPLICATION requests received"),
1261 1, 1261 1,
1262 GNUNET_NO); 1262 GNUNET_NO);
1263 GNUNET_SERVER_client_keep (client); 1263 GNUNET_SERVER_client_keep (client);
@@ -1282,6 +1282,12 @@ handle_get_zero_anonymity (void *cls,
1282 enum GNUNET_BLOCK_Type type; 1282 enum GNUNET_BLOCK_Type type;
1283 1283
1284 type = (enum GNUNET_BLOCK_Type) ntohl (msg->type); 1284 type = (enum GNUNET_BLOCK_Type) ntohl (msg->type);
1285 if (type == GNUNET_BLOCK_TYPE_ANY)
1286 {
1287 GNUNET_break (0);
1288 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1289 return;
1290 }
1285#if DEBUG_DATASTORE 1291#if DEBUG_DATASTORE
1286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1287 "Processing `%s' request\n", 1293 "Processing `%s' request\n",
@@ -1706,7 +1712,7 @@ run (void *cls,
1706 {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE, 1712 {&handle_update, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_UPDATE,
1707 sizeof (struct UpdateMessage) }, 1713 sizeof (struct UpdateMessage) },
1708 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 }, 1714 {&handle_get, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET, 0 },
1709 {&handle_get_random, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_RANDOM, 1715 {&handle_get_replication, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION,
1710 sizeof(struct GNUNET_MessageHeader) }, 1716 sizeof(struct GNUNET_MessageHeader) },
1711 {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, 1717 {&handle_get_zero_anonymity, NULL, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY,
1712 sizeof(struct GetZeroAnonymityMessage) }, 1718 sizeof(struct GetZeroAnonymityMessage) },
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 501c9f292..eca82a6fb 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -1028,12 +1028,14 @@ sqlite_plugin_iter_zero_anonymity (void *cls,
1028 sqlite3_stmt *stmt_2; 1028 sqlite3_stmt *stmt_2;
1029 char *q; 1029 char *q;
1030 1030
1031 GNUNET_assert (type != GNUNET_BLOCK_TYPE_ANY);
1031 now = GNUNET_TIME_absolute_get (); 1032 now = GNUNET_TIME_absolute_get ();
1032 GNUNET_asprintf (&q, 1033 GNUNET_asprintf (&q,
1033 "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " 1034 "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 "
1034 "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND hash < ?2) " 1035 "WHERE (prio = ?1 AND expire > %llu AND anonLevel = 0 AND type=%d AND hash < ?2) "
1035 "ORDER BY hash DESC LIMIT 1", 1036 "ORDER BY hash DESC LIMIT 1",
1036 (unsigned long long) now.abs_value); 1037 (unsigned long long) now.abs_value,
1038 type);
1037 if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK) 1039 if (sq_prepare (plugin->dbh, q, &stmt_1) != SQLITE_OK)
1038 { 1040 {
1039 LOG_SQLITE (plugin, NULL, 1041 LOG_SQLITE (plugin, NULL,
@@ -1046,9 +1048,10 @@ sqlite_plugin_iter_zero_anonymity (void *cls,
1046 GNUNET_free (q); 1048 GNUNET_free (q);
1047 GNUNET_asprintf (&q, 1049 GNUNET_asprintf (&q,
1048 "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 " 1050 "SELECT type,prio,anonLevel,expire,hash,value,_ROWID_ FROM gn090 "
1049 "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0) " 1051 "WHERE (prio < ?1 AND expire > %llu AND anonLevel = 0 AND type=%d) "
1050 "ORDER BY prio DESC, hash DESC LIMIT 1", 1052 "ORDER BY prio DESC, hash DESC LIMIT 1",
1051 (unsigned long long) now.abs_value); 1053 (unsigned long long) now.abs_value,
1054 type);
1052 if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK) 1055 if (sq_prepare (plugin->dbh, q, &stmt_2) != SQLITE_OK)
1053 { 1056 {
1054 LOG_SQLITE (plugin, NULL, 1057 LOG_SQLITE (plugin, NULL,