gchar *hostname;
const gchar *log_tag;
struct rspamd_io_ev *ev;
+ struct rspamd_io_ev *shut_ev;
struct ev_loop *event_loop;
rspamd_ssl_handler_t handler;
rspamd_ssl_error_handler_t err_handler;
G_STRFUNC, \
__VA_ARGS__)
+static void rspamd_ssl_event_handler (gint fd, short what, gpointer ud);
+
INIT_LOG_MODULE(ssl)
static GQuark
g_free (conn->hostname);
}
+ if (conn->shut_ev) {
+ rspamd_ev_watcher_stop (conn->event_loop, conn->shut_ev);
+ g_free (conn->shut_ev);
+ }
+
close (conn->fd);
g_free (conn);
}
}
/* As we own fd, we can try to perform shutdown one more time */
- rspamd_ev_watcher_reschedule (conn->event_loop, conn->ev, what);
+ /* BUGON: but we DO NOT own conn->ev, and it's a big issue */
+ static const ev_tstamp shutdown_time = 5.0;
+
+ rspamd_ev_watcher_stop (conn->event_loop, conn->ev);
+ conn->shut_ev = g_malloc0 (sizeof (*conn->shut_ev));
+ rspamd_ev_watcher_init (conn->shut_ev, conn->fd, what,
+ rspamd_ssl_event_handler, conn);
+ rspamd_ev_watcher_start (conn->event_loop, conn->shut_ev, shutdown_time);
+ /* XXX: can it be done safely ? */
+ conn->ev = conn->shut_ev;
+
conn->state = ssl_next_shutdown;
}
}
msg_debug_ssl ("connected, start write event");
rspamd_ev_watcher_stop (conn->event_loop, ev);
- rspamd_ev_watcher_init (ev, fd, EV_WRITE, rspamd_ssl_event_handler, conn);
+ rspamd_ev_watcher_init (ev, nfd, EV_WRITE, rspamd_ssl_event_handler, conn);
rspamd_ev_watcher_start (conn->event_loop, ev, timeout);
}
else {
}
rspamd_ev_watcher_stop (conn->event_loop, ev);
- rspamd_ev_watcher_init (ev, fd, EV_WRITE|EV_READ,
+ rspamd_ev_watcher_init (ev, nfd, EV_WRITE|EV_READ,
rspamd_ssl_event_handler, conn);
rspamd_ev_watcher_start (conn->event_loop, ev, timeout);
}