[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20266 - gnunet/src/namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20266 - gnunet/src/namestore |
Date: |
Mon, 5 Mar 2012 10:09:52 +0100 |
Author: wachs
Date: 2012-03-05 10:09:52 +0100 (Mon, 05 Mar 2012)
New Revision: 20266
Modified:
gnunet/src/namestore/gnunet-service-namestore.c
gnunet/src/namestore/test_namestore_api_create_update.c
Log:
- expiration update
Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c 2012-03-05 00:59:24 UTC
(rev 20265)
+++ gnunet/src/namestore/gnunet-service-namestore.c 2012-03-05 09:09:52 UTC
(rev 20266)
@@ -622,11 +622,9 @@
(crc->rd->data_size == rd[c].data_size) &&
(0 == memcmp (crc->rd->data, rd[c].data, rd[c].data_size)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing records for `%s' to
update!\n", crc->name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing records for `%s' to
update expiration date!\n", crc->name);
exist = c;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "exp %llu %llu!\n",
rd[c].expiration.abs_value, crc->rd->expiration.abs_value);
if (crc->rd->expiration.abs_value != rd[c].expiration.abs_value)
-
update = GNUNET_YES;
break;
}
@@ -664,6 +662,7 @@
rd_new = GNUNET_malloc ((rd_count) * sizeof (struct
GNUNET_NAMESTORE_RecordData));
memcpy (rd_new, rd, rd_count * sizeof (struct
GNUNET_NAMESTORE_RecordData));
rd_count_new = rd_count;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration from %llu to
%llu!\n", rd_new[exist].expiration.abs_value, crc->rd->expiration.abs_value);
rd_new[exist].expiration = crc->rd->expiration;
signature_new = GNUNET_NAMESTORE_create_signature (crc->pkey, crc->name,
rd_new, rd_count_new);
if (NULL == signature_new)
@@ -689,8 +688,30 @@
GNUNET_free_non_null (rd_new);
GNUNET_free_non_null (signature_new);
+ switch (res) {
+ case GNUNET_SYSERR:
+ /* failed to create the record */
+ crc->res = GNUNET_SYSERR;
+ break;
+ case GNUNET_YES:
+ /* database operations OK */
+ if (GNUNET_YES == update)
+ /* we updated an existing record */
+ crc->res = GNUNET_NO;
+ else
+ /* we created a new record */
+ crc->res = GNUNET_YES;
+ break;
+ case GNUNET_NO:
+ /* identical entry existed, so we did nothing */
+ crc->res = GNUNET_NO;
+ break;
+ default:
+ break;
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Update result for name `%s' %u\n",
crc->name, res);
- crc->res = res;
+
}
static void handle_record_create (void *cls,
Modified: gnunet/src/namestore/test_namestore_api_create_update.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_create_update.c 2012-03-05
00:59:24 UTC (rev 20265)
+++ gnunet/src/namestore/test_namestore_api_create_update.c 2012-03-05
09:09:52 UTC (rev 20266)
@@ -19,7 +19,7 @@
*/
/**
* @file namestore/test_namestore_api.c
- * @brief testcase for namestore_api.c
+ * @brief testcase for namestore_api.c for updating an existing record
*/
#include "platform.h"
#include "gnunet_common.h"
@@ -321,36 +321,40 @@
create_updated_cont (void *cls, int32_t success, const char *emsg)
{
char *name = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create record for `%s': %s `%s'\n",
name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS" : "FAIL",
emsg);
- if (success == GNUNET_OK)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating expiration for record `%s':
%s `%s'\n", name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ?
"SUCCESS" : "FAIL", emsg);
+ if (success == GNUNET_NO)
{
res = 0;
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updated record for name `%s'\n",
name);
}
+ if (success == GNUNET_OK)
+ {
+ res = 1;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAIL, Create new record for name
`%s'\n", name);
+ }
else
{
res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name
`%s'\n", name);
- GNUNET_SCHEDULER_add_now(&end, NULL);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create records for name
`%s'\n", name);
}
-
+ GNUNET_SCHEDULER_add_now(&end, NULL);
}
void
create_identical_cont (void *cls, int32_t success, const char *emsg)
{
char *name = cls;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create updated record for `%s': %s
`%s'\n", name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS"
: "FAIL", emsg);
- if (success == GNUNET_OK)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating identical record for `%s': %s
`%s'\n", name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ? "SUCCESS"
: "FAIL", emsg);
+ if (success == GNUNET_NO)
{
res = 0;
- s_first_record->expiration = GNUNET_TIME_absolute_get_zero();
+ s_first_record->expiration = GNUNET_TIME_absolute_get ();
GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record,
&create_updated_cont, s_name);
}
else
{
res = 1;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name
`%s'\n", name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating identical record for `%s':
%s `%s'\n", name, ((success == GNUNET_YES) || (success == GNUNET_NO)) ?
"SUCCESS" : "FAIL", emsg);
GNUNET_SCHEDULER_add_now(&end, NULL);
}
@@ -402,7 +406,7 @@
for (c = 0; c < count; c++)
{
- rd[c].expiration = GNUNET_TIME_absolute_get();
+ rd[c].expiration = GNUNET_TIME_absolute_get_zero();
rd[c].record_type = TEST_RECORD_TYPE;
rd[c].data_size = TEST_RECORD_DATALEN;
rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20266 - gnunet/src/namestore,
gnunet <=