OpenVPN 3 Core Library
Loading...
Searching...
No Matches
waitbarrier.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
#ifndef OPENVPN_COMMON_WAITBARRIER_H
13
#define OPENVPN_COMMON_WAITBARRIER_H
14
15
#include <
openvpn/common/exception.hpp
>
16
#include <
openvpn/common/pthreadcond.hpp
>
17
18
namespace
openvpn
{
19
20
#ifdef INSTRUMENTATION_SLOWDOWN
21
static
constexpr
unsigned
int
WAIT_BARRIER_TIMEOUT
= 300;
22
#else
23
static
constexpr
unsigned
int
WAIT_BARRIER_TIMEOUT
= 30;
24
#endif
25
26
template
<
typename
THREAD_COMMON>
27
inline
void
event_loop_wait_barrier
(THREAD_COMMON &tc,
28
const
unsigned
int
seconds =
WAIT_BARRIER_TIMEOUT
)
29
{
30
// barrier prior to event-loop entry
31
switch
(tc.event_loop_bar.wait(seconds))
32
{
33
case
PThreadBarrier::SUCCESS
:
34
break
;
35
case
PThreadBarrier::CHOSEN_ONE
:
36
tc.user_group.activate();
37
tc.show_unused_options();
38
tc.event_loop_bar.signal();
39
break
;
40
case
PThreadBarrier::TIMEOUT
:
41
throw
Exception
(
"event loop barrier timeout"
);
42
case
PThreadBarrier::ERROR_SIGNAL
:
43
throw
Exception
(
"event loop barrier error"
);
44
}
45
}
46
}
// namespace openvpn
47
48
#endif
openvpn::Exception
Definition
exception.hpp:38
openvpn::PThreadBarrier::CHOSEN_ONE
@ CHOSEN_ONE
Definition
pthreadcond.hpp:41
openvpn::PThreadBarrier::SUCCESS
@ SUCCESS
Definition
pthreadcond.hpp:40
openvpn::PThreadBarrier::ERROR_SIGNAL
@ ERROR_SIGNAL
Definition
pthreadcond.hpp:43
openvpn::PThreadBarrier::TIMEOUT
@ TIMEOUT
Definition
pthreadcond.hpp:42
exception.hpp
openvpn
Support deferred server-side state creation when client connects.
Definition
ovpncli.cpp:95
openvpn::event_loop_wait_barrier
void event_loop_wait_barrier(THREAD_COMMON &tc, const unsigned int seconds=WAIT_BARRIER_TIMEOUT)
Definition
waitbarrier.hpp:27
openvpn::WAIT_BARRIER_TIMEOUT
static constexpr unsigned int WAIT_BARRIER_TIMEOUT
Definition
waitbarrier.hpp:23
pthreadcond.hpp
openvpn
common
waitbarrier.hpp
Generated by
1.9.8