struct lua_callback_state lcbd;
lua_State *L;
+ if (cbd->cbref == -1) {
+ /* Coroutine-style call: resume the yielded thread with (err, nil) */
+ if (cbd->flags & RSPAMD_LUA_HTTP_FLAG_YIELDED) {
+ cbd->flags &= ~RSPAMD_LUA_HTTP_FLAG_YIELDED;
+
+ L = cbd->thread->lua_state;
+ lua_pushstring(L, err);
+ lua_pushnil(L);
+
+ if (cbd->item) {
+ rspamd_symcache_set_cur_item(cbd->task, cbd->item);
+ }
+
+ lua_thread_resume_checked(cbd->thread, cbd->thread_generation, 2);
+ }
+ else {
+ msg_info("lost HTTP error for %s in coroutines mess: %s",
+ cbd->host ? cbd->host : "unknown host", err);
+ }
+
+ return;
+ }
+
lua_thread_pool_prepare_callback(cbd->cfg->lua_thread_pool, &lcbd);
L = lcbd.L;
msg = rspamd_http_message_from_url(url);
if (msg == NULL) {
msg_err_task_check("cannot create HTTP message from url %s", url);
+
+ if (cbref == -1) {
+ /* Coroutine callers expect (err, response), not a bare false */
+ lua_pushstring(L, "cannot create HTTP message from url");
+ lua_pushnil(L);
+ return 2;
+ }
+
lua_pushboolean(L, FALSE);
return 1;
}
}
if (session && rspamd_session_blocked(session)) {
- lua_pushboolean(L, FALSE);
-
g_free(auth);
rspamd_http_message_unref(msg);
if (body) {
rspamd_keypair_unref(local_kp);
}
+ if (cbref == -1) {
+ /* Coroutine callers expect (err, response), not a bare false */
+ lua_pushstring(L, "session is terminating");
+ lua_pushnil(L);
+
+ return 2;
+ }
+
+ lua_pushboolean(L, FALSE);
+
return 1;
}
if (task == NULL && cfg == NULL) {
}
REF_RELEASE(cbd);
+
+ if (cbref == -1) {
+ /* Coroutine callers expect (err, response), not a bare false */
+ lua_pushstring(L, "cannot make HTTP connection");
+ lua_pushnil(L);
+
+ return 2;
+ }
+
lua_pushboolean(L, FALSE);
return 1;
}
REF_RELEASE(cbd);
+
+ if (cbref == -1) {
+ /* Coroutine callers expect (err, response), not a bare false */
+ lua_pushstring(L, "cannot make DNS request");
+ lua_pushnil(L);
+
+ return 2;
+ }
+
lua_pushboolean(L, FALSE);
return 1;
}
REF_RELEASE(cbd);
+
+ if (cbref == -1) {
+ /* Coroutine callers expect (err, response), not a bare false */
+ lua_pushstring(L, "cannot make DNS request");
+ lua_pushnil(L);
+
+ return 2;
+ }
+
lua_pushboolean(L, FALSE);
return 1;