Add more debugging to destructors in pools.
static gchar *ip;
static gint weight = 1;
static gint flag;
+static gint timeout = 5;
static gboolean pass_all;
static gboolean tty = FALSE;
static gboolean verbose = FALSE;
{ "pass", 'p', 0, G_OPTION_ARG_NONE, &pass_all, "Pass all filters", NULL },
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "More verbose output", NULL },
{ "ip", 'i', 0, G_OPTION_ARG_STRING, &ip, "Emulate that message was received from specified ip address", NULL },
+ { "timeout", 't', 0, G_OPTION_ARG_INT, &timeout, "Timeout for waiting for a reply", NULL },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
rspamd_client_init ();
read_cmd_line (&argc, &argv);
+ rspamd_set_timeout (1000, timeout * 1000);
tty = isatty (STDOUT_FILENO);
/* Now read other args from argc and argv */
if (argc == 1) {
}
void
-memory_pool_add_destructor (memory_pool_t * pool, pool_destruct_func func, void *data)
+memory_pool_add_destructor_full (memory_pool_t * pool, pool_destruct_func func, void *data,
+ const gchar *function, const gchar *line)
{
struct _pool_destructors *cur, *tmp;
while (tmp) {
if (tmp->func == func && tmp->data == data) {
/* Do not add identical destructors, they must be unique */
+ msg_warn ("duplicate desctrutors detected: already have destructor from %s:%s and is trying to add from %s:%s",
+ tmp->function, tmp->loc, function, line);
return;
}
tmp = tmp->prev;
cur->func = func;
cur->data = data;
+ cur->function = function;
+ cur->loc = line;
cur->prev = pool->destructors;
pool->destructors = cur;
}
struct _pool_destructors {
pool_destruct_func func; /**< pointer to destructor */
void *data; /**< data to free */
+ const gchar *function; /**< function from which this destructor was added */
+ const gchar *loc; /**< line number */
struct _pool_destructors *prev; /**< chain link */
};
* @param func pointer to function-destructor
* @param data pointer to data that would be passed to destructor
*/
-void memory_pool_add_destructor (memory_pool_t *pool, pool_destruct_func func, void *data);
+void memory_pool_add_destructor_full (memory_pool_t *pool, pool_destruct_func func, void *data,
+ const gchar *function, const gchar *line);
+
+/* Macros for common usage */
+#define memory_pool_add_destructor(pool, func, data) memory_pool_add_destructor_full(pool, func, data, G_STRFUNC, G_STRLOC)
/**
* Replace destructor callback to pool for specified pointer
r = rspamd_snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url));
if (write (param->sock, url_buf, r) == -1) {
msg_err ("write failed %s to %s", strerror (errno), param->redirector->name);
- remove_normal_event (param->task->s, free_redirector_session, param);
upstream_fail (¶m->redirector->up, param->task->tv.tv_sec);
+ remove_normal_event (param->task->s, free_redirector_session, param);
+
return;
}
param->state = STATE_READ;
else {
msg_info ("<%s> connection to redirector %s timed out while waiting for write",
param->task->message_id, param->redirector->name);
- remove_normal_event (param->task->s, free_redirector_session, param);
upstream_fail (¶m->redirector->up, param->task->tv.tv_sec);
+ remove_normal_event (param->task->s, free_redirector_session, param);
+
return;
}
break;
r = read (param->sock, url_buf, sizeof (url_buf) - 1);
if (r <= 0) {
msg_err ("read failed: %s from %s", strerror (errno), param->redirector->name);
- remove_normal_event (param->task->s, free_redirector_session, param);
upstream_fail (¶m->redirector->up, param->task->tv.tv_sec);
+ remove_normal_event (param->task->s, free_redirector_session, param);
+
return;
}
parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool);
}
}
- remove_normal_event (param->task->s, free_redirector_session, param);
upstream_ok (¶m->redirector->up, param->task->tv.tv_sec);
+ remove_normal_event (param->task->s, free_redirector_session, param);
}
else {
msg_info ("<%s> reading redirector %s timed out, while waiting for read",
param->redirector->name, param->task->message_id);
- remove_normal_event (param->task->s, free_redirector_session, param);
upstream_fail (¶m->redirector->up, param->task->tv.tv_sec);
+ remove_normal_event (param->task->s, free_redirector_session, param);
}
break;
}