what = EV_WRITE;
}
else {
+ rspamd_ev_watcher_stop (c->event_loop, c->ev);
rspamd_tls_set_error (ret, "connect", &err);
c->err_handler (c->handler_data, err);
g_error_free (err);
break;
case ssl_next_write:
case ssl_conn_connected:
- rspamd_ev_watcher_reschedule (c->event_loop, c->ev, EV_WRITE);
+ rspamd_ev_watcher_reschedule (c->event_loop, c->ev, what);
c->state = ssl_conn_connected;
- c->handler (fd, EV_WRITE, c->handler_data);
+ c->handler (fd, what, c->handler_data);
break;
default:
+ rspamd_ev_watcher_stop (c->event_loop, c->ev);
g_set_error (&err, rspamd_ssl_quark (), EINVAL,
"ssl bad state error: %d", c->state);
c->err_handler (c->handler_data, err);
end
local function from_done_cb(err, data, conn)
logger.errx(task, 'FROM: got reply: %s, error: %s', data, err)
- conn:add_write(rcpt_cb, 'RCPT TO: <hui@yandex.ru>\r\n')
+ conn:add_write(rcpt_cb, 'RCPT TO: <test@yandex.ru>\r\n')
end
local function from_cb(err, conn)
logger.errx(task, 'written from, error: %s', err)
enum lua_tcp_handler_type {
LUA_WANT_WRITE = 0,
LUA_WANT_READ,
- LUA_WANT_CONNECT // used only with sync connections
+ LUA_WANT_CONNECT
};
struct lua_tcp_handler {
struct lua_tcp_handler *rh = g_queue_peek_head (cbd->handlers);
event_type = rh->type;
+ rspamd_ev_watcher_stop (cbd->event_loop, &cbd->ev);
+
if (what == EV_READ) {
if (cbd->ssl_conn) {
r = rspamd_ssl_read (cbd->ssl_conn, inbuf, sizeof (inbuf));
g_assert_not_reached ();
}
}
-#ifdef EV_CLOSED
- else if (what == EV_CLOSED) {
- lua_tcp_push_error (cbd, TRUE, "Remote peer has closed the connection");
- TCP_RELEASE (cbd);
- }
-#endif
else {
lua_tcp_push_error (cbd, TRUE, "IO timeout");
TCP_RELEASE (cbd);
}
}
else {
- msg_debug_tcp ("plan new read");
if (can_read) {
/* We need to plan a new event */
+ msg_debug_tcp ("plan new read");
rspamd_ev_watcher_reschedule (cbd->event_loop, &cbd->ev,
EV_READ);
}
else {
/* Cannot read more */
+ msg_debug_tcp ("cannot read more");
lua_tcp_push_error (cbd, FALSE, "EOF, cannot read more data");
- if (!IS_SYNC(cbd)) {
+ if (!IS_SYNC (cbd)) {
lua_tcp_shift_handler (cbd);
lua_tcp_plan_handler_event (cbd, can_read, can_write);
}
}
}
else {
- rspamd_ev_watcher_init (&cbd->ev, cbd->fd, EV_READ|EV_WRITE,
+ rspamd_ev_watcher_init (&cbd->ev, cbd->fd, EV_WRITE,
lua_tcp_handler, cbd);
lua_tcp_register_event (cbd);
lua_tcp_plan_handler_event (cbd, TRUE, TRUE);