[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r12142 - gnunet/src/datacache
From: |
gnunet |
Subject: |
[GNUnet-SVN] r12142 - gnunet/src/datacache |
Date: |
Fri, 2 Jul 2010 23:23:20 +0200 |
Author: grothoff
Date: 2010-07-02 23:23:20 +0200 (Fri, 02 Jul 2010)
New Revision: 12142
Modified:
gnunet/src/datacache/plugin_datacache_sqlite.c
gnunet/src/datacache/test_datacache.c
Log:
fixing issue with sqlite not supporting unsigned 64-bit numbers
Modified: gnunet/src/datacache/plugin_datacache_sqlite.c
===================================================================
--- gnunet/src/datacache/plugin_datacache_sqlite.c 2010-07-02 21:15:39 UTC
(rev 12141)
+++ gnunet/src/datacache/plugin_datacache_sqlite.c 2010-07-02 21:23:20 UTC
(rev 12142)
@@ -104,6 +104,7 @@
{
struct Plugin *plugin = cls;
sqlite3_stmt *stmt;
+ int64_t dval;
#if DEBUG_DATACACHE_SQLITE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -113,6 +114,9 @@
GNUNET_h2s (key),
(unsigned long long) GNUNET_TIME_absolute_get_remaining
(discard_time).value);
#endif
+ dval = (int64_t) discard_time.value;
+ if (dval < 0)
+ dval = INT64_MAX;
if (sq_prepare (plugin->dbh,
"INSERT INTO ds090 "
"(type, expire, key, value) "
@@ -125,7 +129,7 @@
return 0;
}
if ( (SQLITE_OK != sqlite3_bind_int (stmt, 1, type)) ||
- (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, discard_time.value)) ||
+ (SQLITE_OK != sqlite3_bind_int64 (stmt, 2, dval)) ||
(SQLITE_OK != sqlite3_bind_blob (stmt, 3, key, sizeof (GNUNET_HashCode),
SQLITE_TRANSIENT)) ||
(SQLITE_OK != sqlite3_bind_blob (stmt, 4, data, size,
SQLITE_TRANSIENT)))
@@ -180,6 +184,7 @@
unsigned int off;
unsigned int total;
char scratch[256];
+ int64_t ntime;
now = GNUNET_TIME_absolute_get ();
#if DEBUG_DATACACHE_SQLITE
@@ -201,6 +206,8 @@
sqlite3_bind_blob (stmt, 1, key, sizeof (GNUNET_HashCode),
SQLITE_TRANSIENT);
sqlite3_bind_int (stmt, 2, type);
+ ntime = (int64_t) now.value;
+ GNUNET_assert (ntime >= 0);
sqlite3_bind_int64 (stmt, 3, now.value);
if (SQLITE_ROW != sqlite3_step (stmt))
{
@@ -241,6 +248,9 @@
size = sqlite3_column_bytes (stmt, 0);
dat = sqlite3_column_blob (stmt, 0);
exp.value = sqlite3_column_int64 (stmt, 1);
+ ntime = (int64_t) exp.value;
+ if (ntime == INT64_MAX)
+ exp = GNUNET_TIME_UNIT_FOREVER_ABS;
cnt++;
if (GNUNET_OK != iter (iter_cls,
exp,
Modified: gnunet/src/datacache/test_datacache.c
===================================================================
--- gnunet/src/datacache/test_datacache.c 2010-07-02 21:15:39 UTC (rev
12141)
+++ gnunet/src/datacache/test_datacache.c 2010-07-02 21:23:20 UTC (rev
12142)
@@ -106,7 +106,7 @@
(const char *) &n,
792,
GNUNET_TIME_UNIT_FOREVER_ABS));
- ASSERT (1 ==
+ ASSERT (0 !=
GNUNET_DATACACHE_get (h, &k, 792,
&checkIt, &n));
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r12142 - gnunet/src/datacache,
gnunet <=