gint err_idx;
g_assert (ctx != NULL);
+ g_assert (task != NULL);
stcf = ctx->stcf;
L = task->cfg->lua_state;
+ g_assert (L != NULL);
if (ctx->enable_users) {
if (ctx->cbref_user == -1) {
rcpt = rspamd_task_get_principal_recipient (task);
}
- else if (L) {
+ else {
/* Execute lua function to get userdata */
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);
}
- if (target == NULL || task == NULL) {
+ if (target == NULL) {
return -1;
}
rspamd_snprintf (lock_path, sizeof (lock_path), "%s.lock", path);
lock_fd = open (lock_path, O_WRONLY|O_CREAT|O_EXCL, 00600);
- if (lock_fd == -1 && (errno == EEXIST || errno == EBUSY)) {
- msg_debug_pool_check ("checking %s to wait for db being initialized", lock_path);
+ if (lock_fd == -1) {
+ if (errno == EEXIST || errno == EBUSY) {
+ msg_debug_pool_check ("checking %s to wait for db being initialized", lock_path);
- if (!rspamd_sqlite3_wait (pool, lock_path)) {
- g_set_error (err, rspamd_sqlite3_quark (),
- errno, "cannot create sqlite file %s: %s",
- path, strerror (errno));
+ if (!rspamd_sqlite3_wait(pool, lock_path)) {
+ g_set_error(err, rspamd_sqlite3_quark(),
+ errno, "cannot create sqlite file %s: %s",
+ path, strerror(errno));
- return NULL;
- }
+ return NULL;
+ }
- /* At this point we have database created */
- create = FALSE;
- has_lock = FALSE;
+
+ /* At this point we have database created */
+ create = FALSE;
+ has_lock = FALSE;
+ }
+ else {
+ g_set_error(err, rspamd_sqlite3_quark(),
+ errno, "cannot lock sqlite file %s: %s",
+ path, strerror(errno));
+ }
}
else {
pid_t myself = getpid ();
/* Set PRNG */
lua_getglobal (L, "math");
- lua_pushstring (L, "randomseed");
+ lua_pushstring (L, "randomseed"); /* Push math.randomseed function on top of the stack */
lua_gettable (L, -2);
lua_pushinteger (L, ottery_rand_uint64 ());
- lua_pcall (L, 1, 0, 0);
+ g_assert (lua_pcall (L, 1, 0, 0) == 0);
lua_pop (L, 1); /* math table */
/* Modules state */
fuzzy_lua_unlearn_handler (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);
+ g_assert (task != NULL);
guint flag = 0, weight = 1.0, send_flags = 0;
const gchar *symbol;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context (task->cfg);