aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-01 16:45:38 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-03-01 16:45:38 +0400
commit7dcf9f9bade26ca02b8706a2e4cb2066f6ba7b00 (patch)
treef69121ee5c1a0e43fe987db8ed2c9e5cc66c79f0
parentc93cca709b13da41b8d5bcd08874d75669e125f0 (diff)
downloadrspamd-7dcf9f9bade26ca02b8706a2e4cb2066f6ba7b00.tar.gz
rspamd-7dcf9f9bade26ca02b8706a2e4cb2066f6ba7b00.zip
Use DB_HASH access method for bdb backend.
Fix signed and unsigned comparasion while I'm here.
-rw-r--r--lib/client/librspamdclient.c30
-rw-r--r--lib/kvstorage/libkvstorageclient.c12
-rw-r--r--src/binlog.c2
-rw-r--r--src/buffer.c2
-rw-r--r--src/cfg_utils.c2
-rw-r--r--src/html.c2
-rw-r--r--src/kvstorage.c4
-rw-r--r--src/kvstorage_bdb.c7
-rw-r--r--src/kvstorage_file.c2
-rw-r--r--src/url.c2
10 files changed, 35 insertions, 30 deletions
diff --git a/lib/client/librspamdclient.c b/lib/client/librspamdclient.c
index dad2a3388..2488abd37 100644
--- a/lib/client/librspamdclient.c
+++ b/lib/client/librspamdclient.c
@@ -328,7 +328,7 @@ parse_rspamd_first_line (struct rspamd_connection *conn, guint len, GError **err
p = b;
c = p;
- while (p - b < remain) {
+ while (p - b < (gint)remain) {
switch (state) {
case 0:
/* Read version */
@@ -359,7 +359,7 @@ parse_rspamd_first_line (struct rspamd_connection *conn, guint len, GError **err
break;
case 2:
/* Read message */
- if (g_ascii_isspace (*p) || p - b == remain - 1) {
+ if (g_ascii_isspace (*p) || p - b == (gint)remain - 1) {
state = 99;
next_state = 3;
}
@@ -411,7 +411,7 @@ parse_rspamd_metric_line (struct rspamd_connection *conn, guint len, GError **er
}
c = p;
- while (p - b < remain) {
+ while (p - b < (gint)remain) {
switch (state) {
case 0:
/* Read metric's name */
@@ -475,7 +475,7 @@ parse_rspamd_metric_line (struct rspamd_connection *conn, guint len, GError **er
break;
case 4:
/* Read required score */
- if (g_ascii_isspace (*p) || p - b == remain - 1) {
+ if (g_ascii_isspace (*p) || p - b == (gint)remain - 1) {
new->required_score = strtod (c, &err_str);
if (*err_str != *p && *err_str != *(p + 1)) {
/* Invalid score */
@@ -499,7 +499,7 @@ parse_rspamd_metric_line (struct rspamd_connection *conn, guint len, GError **er
break;
case 6:
/* Read reject score */
- if (g_ascii_isspace (*p) || p - b == remain - 1) {
+ if (g_ascii_isspace (*p) || p - b == (gint)remain - 1) {
new->reject_score = strtod (c, &err_str);
if (*err_str != *p && *err_str != *(p + 1)) {
/* Invalid score */
@@ -551,17 +551,17 @@ parse_rspamd_symbol_line (struct rspamd_connection *conn, guint len, GError **er
p ++;
}
c = p;
- while (p - b < remain) {
+ while (p - b < (gint)remain) {
switch (state) {
case 0:
/* Read symbol's name */
- if (p - b == remain - 1 || *p == ';' || *p == '(') {
+ if (p - b == (gint)remain - 1 || *p == ';' || *p == '(') {
if (p - c <= 1) {
/* Empty symbol name */
goto err;
}
else {
- if (p - b == remain - 1) {
+ if (p - b == (gint)remain - 1) {
l = p - c + 1;
}
else {
@@ -614,7 +614,7 @@ parse_rspamd_symbol_line (struct rspamd_connection *conn, guint len, GError **er
break;
case 2:
/* Read description */
- if (*p == ';' || p - b == remain - 1) {
+ if (*p == ';' || p - b == (gint)remain - 1) {
if (*p == ';') {
l = p - c;
}
@@ -635,10 +635,10 @@ parse_rspamd_symbol_line (struct rspamd_connection *conn, guint len, GError **er
break;
case 3:
/* Read option */
- if (*p == ',' || p - b == remain - 1) {
+ if (*p == ',' || p - b == (gint)remain - 1) {
/* Insert option into linked list */
l = p - c;
- if (p - b == remain - 1) {
+ if (p - b == (gint)remain - 1) {
l ++;
}
sym = g_malloc (l + 1);
@@ -688,7 +688,7 @@ parse_rspamd_action_line (struct rspamd_connection *conn, guint len, GError **er
p = b;
c = b;
- while (p - b < remain) {
+ while (p - b < (gint)remain) {
switch (state) {
case 0:
/* Read action */
@@ -701,7 +701,7 @@ parse_rspamd_action_line (struct rspamd_connection *conn, guint len, GError **er
}
break;
case 1:
- if (p - b == remain - 1) {
+ if (p - b == (gint)remain - 1) {
if (p - c <= 1) {
/* Empty action name */
goto err;
@@ -756,7 +756,7 @@ parse_rspamd_header_line (struct rspamd_connection *conn, guint len, GError **er
p = b;
c = b;
- while (p - b < remain) {
+ while (p - b < (gint)remain) {
switch (state) {
case 0:
/* Read header name */
@@ -777,7 +777,7 @@ parse_rspamd_header_line (struct rspamd_connection *conn, guint len, GError **er
p ++;
break;
case 1:
- if (p - b == remain - 1) {
+ if (p - b == (gint)remain - 1) {
if (p - c <= 1) {
/* Empty action name */
goto err;
diff --git a/lib/kvstorage/libkvstorageclient.c b/lib/kvstorage/libkvstorageclient.c
index d05e8b5e0..10e9be8a4 100644
--- a/lib/kvstorage/libkvstorageclient.c
+++ b/lib/kvstorage/libkvstorageclient.c
@@ -182,10 +182,10 @@ rspamd_kvstorage_buf_drainline (struct kvstorage_buf *buf)
p = buf->data + buf->pos;
/* Skip \r and \n characters */
- while (p - buf->data < buf->len && (*p == '\r' || *p == '\n')) {
+ while (p - buf->data < (gint)buf->len && (*p == '\r' || *p == '\n')) {
p ++;
}
- if (p - buf->data == buf->len) {
+ if (p - buf->data == (gint)buf->len) {
/* Do not move anything */
buf->pos = 0;
return;
@@ -207,9 +207,9 @@ rspamd_kvstorage_parse_reply_error (struct kvstorage_buf *buf)
/* Get one word */
p = buf->data;
- while (p - buf->data < buf->pos) {
+ while (p - buf->data < (gint)buf->pos) {
if (g_ascii_isspace (*p)) {
- while (p - buf->data < buf->pos && g_ascii_isspace (*p)) {
+ while (p - buf->data < (gint)buf->pos && g_ascii_isspace (*p)) {
p ++;
}
break;
@@ -262,7 +262,7 @@ rspamd_kvstorage_parse_get_line (struct kvstorage_buf *buf, guint *len, guint *f
while (p < end) {
if (g_ascii_isspace (*p)) {
error = FALSE;
- while (p - buf->data < buf->pos && g_ascii_isspace (*p)) {
+ while (p - buf->data < (gint)buf->pos && g_ascii_isspace (*p)) {
p ++;
}
break;
@@ -302,7 +302,7 @@ rspamd_kvstorage_parse_get_line (struct kvstorage_buf *buf, guint *len, guint *f
if (g_ascii_isspace (*p)) {
error = FALSE;
/* Skip spaces after flags */
- while (p - buf->data < buf->pos && g_ascii_isspace (*p)) {
+ while (p - buf->data < (gint)buf->pos && g_ascii_isspace (*p)) {
p ++;
}
break;
diff --git a/src/binlog.c b/src/binlog.c
index f87a81b00..47070b3af 100644
--- a/src/binlog.c
+++ b/src/binlog.c
@@ -483,7 +483,7 @@ binlog_sync (struct rspamd_binlog *log, guint64 from_rev, guint64 *from_time, GB
}
(*rep)->data = g_malloc (idx->len);
- if ((read (log->fd, (*rep)->data, idx->len)) != idx->len) {
+ if ((read (log->fd, (*rep)->data, idx->len)) != (ssize_t)idx->len) {
msg_warn ("cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
res = FALSE;
goto end;
diff --git a/src/buffer.c b/src/buffer.c
index 5c7cae197..d5bf673dd 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -224,7 +224,7 @@ write_buffers (gint fd, rspamd_io_dispatcher_t * d, gboolean is_delayed)
while (cur) {
buf = cur->data;
blen = BUFREMAIN (buf);
- if (r >= blen) {
+ if (r >= (ssize_t)blen) {
tmp = cur;
cur = g_list_previous (cur);
/* Mark this buffer as read */
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index f7d1b7ecf..f91882f98 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -294,7 +294,7 @@ parse_limit (const gchar *limit, guint len)
else if (*err_str == 'g' || *err_str == 'G') {
result *= 1073741824L;
}
- else if (len > 0 && err_str - limit != len) {
+ else if (len > 0 && err_str - limit != (gint)len) {
msg_warn ("invalid limit value '%s' at position '%s'", limit, err_str);
result = 0;
}
diff --git a/src/html.c b/src/html.c
index 04dfdfa89..dac09bf0e 100644
--- a/src/html.c
+++ b/src/html.c
@@ -578,7 +578,7 @@ decode_entitles (gchar *s, guint * len)
l = *len;
}
- while (h - s < l) {
+ while (h - s < (gint)l) {
switch (state) {
/* Out of entitle */
case 0:
diff --git a/src/kvstorage.c b/src/kvstorage.c
index f02f6a568..37d2022d9 100644
--- a/src/kvstorage.c
+++ b/src/kvstorage.c
@@ -403,7 +403,7 @@ rspamd_kv_storage_lookup (struct rspamd_kv_storage *storage, gpointer key, guint
if (elt && (elt->flags & KV_ELT_PERSISTENT) == 0 && elt->expire > 0) {
/* Check expiration */
- if (now - elt->age > elt->expire) {
+ if (now - elt->age > (gint)elt->expire) {
/* Set need expire as we have no write lock here */
elt->flags |= KV_ELT_NEED_EXPIRE;
elt = NULL;
@@ -639,7 +639,7 @@ rspamd_lru_expire_step (struct rspamd_kv_expire *e, struct rspamd_kv_storage *st
/* Check other elements in this queue */
TAILQ_FOREACH_SAFE (elt, &expire->head, entry, temp) {
if ((!forced &&
- (elt->flags & (KV_ELT_PERSISTENT|KV_ELT_DIRTY)) != 0) || elt->expire < (now - elt->age)) {
+ (elt->flags & (KV_ELT_PERSISTENT|KV_ELT_DIRTY)) != 0) || (gint)elt->expire < (now - elt->age)) {
break;
}
storage->memory -= ELT_SIZE (elt);
diff --git a/src/kvstorage_bdb.c b/src/kvstorage_bdb.c
index 99203285a..7970291f6 100644
--- a/src/kvstorage_bdb.c
+++ b/src/kvstorage_bdb.c
@@ -157,13 +157,18 @@ rspamd_bdb_init (struct rspamd_kv_backend *backend)
*/
db->envp->set_lk_detect (db->envp, DB_LOCK_DEFAULT);
+ /*
+ * Avoid explicit sync on committing
+ */
+ db->envp->set_flags (db->envp, DB_TXN_NOSYNC, 1);
+
flags = DB_CREATE | DB_THREAD;
/* Create and open db pointer */
if ((ret = db_create (&db->dbp, db->envp, 0)) != 0) {
goto err;
}
- if ((ret = db->dbp->open (db->dbp, NULL, db->filename, NULL, DB_BTREE, flags, 0)) != 0) {
+ if ((ret = db->dbp->open (db->dbp, NULL, db->filename, NULL, DB_HASH, flags, 0)) != 0) {
goto err;
}
diff --git a/src/kvstorage_file.c b/src/kvstorage_file.c
index de06f778b..2857e680b 100644
--- a/src/kvstorage_file.c
+++ b/src/kvstorage_file.c
@@ -89,7 +89,7 @@ get_file_name (struct rspamd_file_backend *db, gchar *key, guint keylen, gchar *
}
/* Now we have directory, append base64 encoded filename */
k = key;
- if (end - p < keylen * 2 + 1) {
+ if (end - p < (gint)keylen * 2 + 1) {
/* Filebuf is not large enough */
return FALSE;
}
diff --git a/src/url.c b/src/url.c
index ade68ea1c..4936d9353 100644
--- a/src/url.c
+++ b/src/url.c
@@ -818,7 +818,7 @@ parse_uri (struct uri *uri, gchar *uristring, memory_pool_t * pool)
return URI_ERRNO_NO_PORT_COLON;
/* We only use 8 bits for portlen so better check */
- if (uri->portlen != port_end - host_end)
+ if ((gint)uri->portlen != port_end - host_end)
return URI_ERRNO_INVALID_PORT;
/* test if port is number */