const gchar *what)
{
lua_State *L = ctx->L;
- struct upstream_list *res;
+ struct upstream_list *res = NULL;
lua_rawgeti (L, LUA_REGISTRYINDEX, ctx->conf_ref);
lua_pushstring (L, what);
lua_gettable (L, -2);
- res = *((struct upstream_list**)lua_touserdata (L, -1));
+
+ if (lua_type (L, -1) == LUA_TUSERDATA) {
+ res = *((struct upstream_list **) lua_touserdata (L, -1));
+ }
+
lua_settop (L, 0);
return res;
g_assert (backend != NULL);
+ ups = rspamd_redis_get_servers (backend, "read_servers");
+ if (!ups) {
+ if (cb) {
+ memset (&rep, 0, sizeof (rep));
+ cb (&rep, ud);
+ }
+
+ return;
+ }
+
session = g_malloc0 (sizeof (*session));
session->backend = backend;
REF_RETAIN (session->backend);
session->argv_lens[4] = 1;
g_string_free (key, FALSE); /* Do not free underlying array */
- ups = rspamd_redis_get_servers (backend, "read_servers");
up = rspamd_upstream_get (ups,
RSPAMD_UPSTREAM_ROUND_ROBIN,
NULL,
g_assert (backend != NULL);
+ ups = rspamd_redis_get_servers (backend, "read_servers");
+ if (!ups) {
+ if (cb) {
+ cb (0, ud);
+ }
+
+ return;
+ }
+
session = g_malloc0 (sizeof (*session));
session->backend = backend;
REF_RETAIN (session->backend);
session->argv_lens[1] = key->len;
g_string_free (key, FALSE); /* Do not free underlying array */
- ups = rspamd_redis_get_servers (backend, "read_servers");
up = rspamd_upstream_get (ups,
RSPAMD_UPSTREAM_ROUND_ROBIN,
NULL,
g_assert (backend != NULL);
+ ups = rspamd_redis_get_servers (backend, "read_servers");
+ if (!ups) {
+ if (cb) {
+ cb (0, ud);
+ }
+
+ return;
+ }
+
session = g_malloc0 (sizeof (*session));
session->backend = backend;
REF_RETAIN (session->backend);
session->argv_lens[1] = key->len;
g_string_free (key, FALSE); /* Do not free underlying array */
- ups = rspamd_redis_get_servers (backend, "read_servers");
up = rspamd_upstream_get (ups,
RSPAMD_UPSTREAM_ROUND_ROBIN,
NULL,
g_assert (backend != NULL);
+ ups = rspamd_redis_get_servers (backend, "write_servers");
+ if (!ups) {
+ if (cb) {
+ cb (FALSE, 0, 0, 0, 0, ud);
+ }
+
+ return;
+ }
+
session = g_malloc0 (sizeof (*session));
session->backend = backend;
REF_RETAIN (session->backend);
session->cbdata = ud;
session->command = RSPAMD_FUZZY_REDIS_COMMAND_UPDATES;
session->cmd = cmd;
- session->prob = 1.0;
+ session->prob = 1.0f;
session->event_loop = rspamd_fuzzy_backend_event_base (bk);
/* First of all check digest */
session->argv = g_malloc0 (sizeof (gchar *) * session->nargs);
session->argv_lens = g_malloc0 (sizeof (gsize) * session->nargs);
- ups = rspamd_redis_get_servers (backend, "write_servers");
up = rspamd_upstream_get (ups,
RSPAMD_UPSTREAM_MASTER_SLAVE,
NULL,