mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
dtls connection setup: fix memory corruption, proper watcher setup
ev_init and ev_io_set must never be called on active watchers - we need to cleanup previous connection state before setting a new one. ev_init clears the "active" flag, but doesn't remove the watcher from libev internal linked lists (and doesn't clear the "next" pointer for it). This can for example lead to (unexpected) cyclic lists in libev, and libev can loop forever trying to deal with them.
This commit is contained in:
@@ -431,7 +431,7 @@ static int setup_dtls_connection(struct worker_st *ws, struct dtls_st * dtls)
|
||||
}
|
||||
|
||||
dtls->dtls_session = session;
|
||||
ev_init(&dtls->io, dtls_watcher_cb);
|
||||
ev_io_stop(worker_loop, &dtls->io);
|
||||
ev_io_set(&dtls->io, dtls->dtls_tptr.fd, EV_READ);
|
||||
ev_io_start(worker_loop, &dtls->io);
|
||||
ev_invoke(worker_loop, &dtls->io, EV_READ);
|
||||
|
||||
Reference in New Issue
Block a user