summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-14 20:02:48 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-14 20:02:48 +0400
commit3fbcf7f04616acf1f367af6d1c9c7ac271edf551 (patch)
tree2b3a800aff2df708da5a548aa9fc9e7d9dfb8e4c
parent95e1c49982ab09db2e2fa799886edd32bebb1404 (diff)
downloadrspamd-3fbcf7f04616acf1f367af6d1c9c7ac271edf551.tar.gz
rspamd-3fbcf7f04616acf1f367af6d1c9c7ac271edf551.zip
* Sync log before closing
* Fix buffer allocation while reading json data
-rw-r--r--src/json/hashtable.c2
-rw-r--r--src/settings.c2
-rw-r--r--src/util.c5
3 files changed, 7 insertions, 2 deletions
diff --git a/src/json/hashtable.c b/src/json/hashtable.c
index b3ea0d62a..43e851382 100644
--- a/src/json/hashtable.c
+++ b/src/json/hashtable.c
@@ -235,7 +235,7 @@ hashtable_close (hashtable_t * hashtable)
hashtable->free_key (pair->key);
if (hashtable->free_value)
hashtable->free_value (pair->value);
- g_free (pair);
+ g_free (pair);
}
g_free (hashtable->buckets);
diff --git a/src/settings.c b/src/settings.c
index 75ba04c76..5ee37d4ed 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -82,7 +82,7 @@ json_read_cb (memory_pool_t *pool, u_char *chunk, size_t len, struct map_cb_data
free = jb->buflen - off;
if (free < len) {
- jb->buflen = MAX (free * 2, len * 2);
+ jb->buflen = MAX (jb->buflen * 2, jb->buflen + len * 2);
jb->buf = g_realloc (jb->buf, jb->buflen);
jb->pos = jb->buf + off;
}
diff --git a/src/util.c b/src/util.c
index 61cf56725..7d074a174 100644
--- a/src/util.c
+++ b/src/util.c
@@ -681,7 +681,12 @@ close_log (struct config_file *cfg)
break;
case RSPAMD_LOG_FILE:
if (cfg->logf != NULL) {
+ if (fsync (cfg->log_fd) == -1) {
+ msg_err ("close_log: error syncing log file: %s", strerror (errno));
+ }
fclose (cfg->logf);
+ /* XXX: I think this is not needed */
+ close (cfg->log_fd);
}
break;
}