expiration.abs_value_us))
plugin->api->update (plugin->api->cls,
uid,
- (int32_t) ntohl (dm->priority),
+ ntohl (dm->priority),
GNUNET_TIME_absolute_ntoh (dm->expiration),
&check_present_continuation,
pc->client);
* @param cls our `struct Plugin *`
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
static void
heap_plugin_update (void *cls,
uint64_t uid,
- int delta,
+ uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont,
void *cont_cls)
GNUNET_CONTAINER_heap_update_cost (value->expire_heap,
expire.abs_value_us);
}
- if ( (delta < 0) && (value->priority < - delta) )
- value->priority = 0;
+ /* Saturating add, don't overflow */
+ if (value->priority > UINT32_MAX - delta)
+ value->priority = UINT32_MAX;
else
value->priority += delta;
cont (cont_cls, GNUNET_OK, NULL);
* @param cls our "struct Plugin*"
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
static void
mysql_plugin_update (void *cls,
uint64_t uid,
- int delta,
+ uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont,
void *cont_cls)
{
struct Plugin *plugin = cls;
- uint32_t idelta = (uint32_t) delta;
uint64_t lexpire = expire.abs_value_us;
int ret;
GNUNET_STRINGS_absolute_time_to_string (expire));
struct GNUNET_MY_QueryParam params_update[] = {
- GNUNET_MY_query_param_uint32 (&idelta),
+ GNUNET_MY_query_param_uint32 (&delta),
GNUNET_MY_query_param_uint64 (&lexpire),
GNUNET_MY_query_param_uint64 (&lexpire),
GNUNET_MY_query_param_uint64 (&uid),
if (NULL == plugin->dbh)
return GNUNET_SYSERR;
+ /* FIXME: PostgreSQL does not have unsigned integers! This is ok for the type column because
+ * we only test equality on it and can cast it to/from uint32_t. For repl, prio, and anonLevel
+ * we do math or inequality tests, so we can't handle the entire range of uint32_t.
+ * This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
+ */
ret =
PQexec (plugin->dbh,
"CREATE TABLE IF NOT EXISTS gn090 ("
* @param cls our `struct Plugin *`
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
static void
postgres_plugin_update (void *cls,
uint64_t uid,
- int delta,
+ uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont,
void *cont_cls)
{
struct Plugin *plugin = cls;
- uint32_t idelta = delta;
uint32_t oid = (uint32_t) uid;
struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_uint32 (&idelta),
+ GNUNET_PQ_query_param_uint32 (&delta),
GNUNET_PQ_query_param_absolute_time (&expire),
GNUNET_PQ_query_param_uint32 (&oid),
GNUNET_PQ_query_param_end
sq_prepare (plugin->dbh,
"SELECT 1 FROM sqlite_master WHERE tbl_name = 'gn090'",
&stmt));
+
+ /* FIXME: SQLite does not have unsigned integers! This is ok for the type column because
+ * we only test equality on it and can cast it to/from uint32_t. For repl, prio, and anonLevel
+ * we do math or inequality tests, so we can't handle the entire range of uint32_t.
+ * This will also cause problems for expiration times after 294247-01-10-04:00:54 UTC.
+ */
if ((sqlite3_step (stmt) == SQLITE_DONE) &&
(sqlite3_exec
(plugin->dbh,
* @param cls the plugin context (state for this module)
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
static void
sqlite_plugin_update (void *cls,
uint64_t uid,
- int delta,
+ uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont,
void *cont_cls)
* @param cls our "struct Plugin*"
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
* @param cons_cls continuation closure
*/
static void
-template_plugin_update (void *cls, uint64_t uid, int delta,
+template_plugin_update (void *cls, uint64_t uid, uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont, void *cont_cls)
{
* @param cls closure
* @param uid unique identifier of the datum
* @param delta by how much should the priority
- * change? If priority + delta < 0 the
- * priority should be set to 0 (never go
- * negative).
+ * change?
* @param expire new expiration time should be the
* MAX of any existing expiration time and
* this value
typedef void
(*PluginUpdate) (void *cls,
uint64_t uid,
- int delta,
+ uint32_t delta,
struct GNUNET_TIME_Absolute expire,
PluginUpdateCont cont,
void *cont_cls);