Browse Source

Fix some memory issues

tags/1.1.0
Vsevolod Stakhov 8 years ago
parent
commit
88a9da36c5
2 changed files with 13 additions and 10 deletions
  1. 12
    9
      src/libserver/fuzzy_backend.c
  2. 1
    1
      src/libutil/upstream.c

+ 12
- 9
src/libserver/fuzzy_backend.c View File

@@ -685,15 +685,11 @@ rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
gint64 number;
};

if (backend == NULL) {
return FALSE;
}

/* Do not do more than 5k ops per step */
const guint64 max_changes = 5000;
gboolean ret = FALSE;
gint64 expire_lim, expired;
gint rc, i;
gint rc, i, orphaned_cnt = 0;
GError *err = NULL;
static const gchar orphaned_shingles[] = "SELECT shingles.value,shingles.number "
"FROM shingles "
@@ -704,6 +700,11 @@ rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
GArray *orphaned;
struct orphaned_shingle_elt orphaned_elt, *pelt;


if (backend == NULL) {
return FALSE;
}

/* Perform expire */
if (expire > 0) {
expire_lim = time (NULL) - expire;
@@ -779,13 +780,14 @@ rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
}

sqlite3_finalize (stmt);
orphaned_cnt = orphaned->len;

if (orphaned->len > 0) {
if (orphaned_cnt > 0) {
msg_info_fuzzy_backend (
"going to delete %ud orphaned shingles",
orphaned->len);
orphaned_cnt);
/* Need to delete orphaned elements */
for (i = 0; i < (gint) orphaned->len; i++) {
for (i = 0; i < (gint) orphaned_cnt; i++) {
pelt = &g_array_index (orphaned,
struct orphaned_shingle_elt,
i);
@@ -795,6 +797,7 @@ rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
}
}


g_array_free (orphaned, TRUE);
}

@@ -804,7 +807,7 @@ rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
if (ret == SQLITE_OK) {
msg_info_fuzzy_backend (
"deleted %ud orphaned shingles",
orphaned->len);
orphaned_cnt);
}
else {
msg_warn_fuzzy_backend (

+ 1
- 1
src/libutil/upstream.c View File

@@ -463,7 +463,7 @@ rspamd_upstream_dtor (struct upstream *up)
g_queue_delete_link (up->ctx->upstreams, up->ctx_pos);
REF_RELEASE (up->ctx);
}
g_list_free (up->ctx_pos);
g_slice_free1 (sizeof (*up), up);
}


Loading…
Cancel
Save