if (cbd->session) {
event_finalizer_t fin = IS_SYNC (cbd) ? lua_tcp_void_finalyser : lua_tcp_fin;
- cbd->async_ev = rspamd_session_add_event (cbd->session, NULL, fin, cbd, g_quark_from_static_string ("lua tcp"));
+ cbd->async_ev = rspamd_session_add_event (cbd->session, NULL, fin, cbd,
+ g_quark_from_static_string ("lua tcp"));
if (!cbd->async_ev) {
return FALSE;
return FALSE;
}
- cbd->flags |= LUA_TCP_FLAG_RESOLVED;
+ if (!(cbd->flags & LUA_TCP_FLAG_RESOLVED)) {
+ /* We come here without resolving, so we need to add a watcher */
+ lua_tcp_register_watcher (cbd);
+ }
+ else {
+ cbd->flags |= LUA_TCP_FLAG_RESOLVED;
+ }
+
lua_tcp_register_event (cbd);
cbd->fd = fd;
TCP_RELEASE (cbd);
}
else {
+ /*
+ * We set this flag as it means that we have already registered the watcher
+ * when started DNS query
+ */
+ cbd->flags |= LUA_TCP_FLAG_RESOLVED;
+
if (reply->entries->type == RDNS_REQUEST_A) {
cbd->addr = rspamd_inet_address_new (AF_INET,
&reply->entries->content.a.addr);
return 1;
}
-
- lua_tcp_register_watcher (cbd);
}
if (rspamd_parse_inet_address (&cbd->addr, host, 0)) {
return 1;
}
+ else {
+ lua_tcp_register_watcher (cbd);
+ }
}
else {
if (!make_dns_request_task (task, lua_tcp_dns_handler, cbd,
return 1;
}
+ else {
+ lua_tcp_register_watcher (cbd);
+ }
}
}
return 2;
}
-
- lua_tcp_register_watcher (cbd);
}
if (rspamd_parse_inet_address (&cbd->addr, host, 0)) {
return 2;
}
+ else {
+ lua_tcp_register_watcher (cbd);
+ }
}
else {
if (!make_dns_request_task (task, lua_tcp_dns_handler, cbd,
return 2;
}
+ else {
+ lua_tcp_register_watcher (cbd);
+ }
}
}
lua_tcp_plan_handler_event (cbd, TRUE, TRUE);
TCP_RETAIN (cbd);
- // lua_tcp_register_event (cbd);
return lua_thread_yield (thread, 0);
}