Skip to content

Commit

Permalink
dco-win: fix reconnect with dco-win driver
Browse files Browse the repository at this point in the history
DCO device is "exclusive" device, meaning that only one app at the time can access it
and device is considered opened until pending IO is complete.

start_impl_() might be called on reconnect, in the same stack with closing device handle.
Closing handle also triggers completion of pending IO, such as async read. However this happens
in the next iteration of ASIO even loop. Therefore we defer opening DCO device
(i.e. calling start_impl_) to let ASIO complete pending IO.

Note that this is not required when async resolve is performed, since this implies deferring.

Signed-off-by: Lev Stipakov <[email protected]>
  • Loading branch information
lstipakov committed Jul 1, 2022
1 parent 37d312d commit e1a3502
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openvpn/dco/ovpndcowincli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ class OvpnDcoWinClient : public Client, public KoRekey::Receiver {
RemoteList& rl = *config->transport.remote_list;
if (rl.endpoint_available(&server_host, &server_port, &proto_))
{
start_impl_();
// defer to let pending IO finish
openvpn_io::post(io_context, [self=Ptr(this)]()
{
OPENVPN_ASYNC_HANDLER;
self->start_impl_();
});
}
else
{
Expand Down

0 comments on commit e1a3502

Please sign in to comment.