The check event_timeout_defined in check_connection_established is
completely redundant as event_timeout_trigger will do the very same
check as first action. Removing this check makes the function
superfluous. To further improve the code move the call check if the
time is expired into process_coarse_timers
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200725234803.22058-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20588.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -139,21 +139,6 @@ check_incoming_control_channel(struct context *c) |
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 | 141 |
/* |
| 142 |
- * Options like --up-delay need to be triggered by this function which |
|
| 143 |
- * checks for connection establishment. |
|
| 144 |
- */ |
|
| 145 |
-static inline void |
|
| 146 |
-check_connection_established(struct context *c) |
|
| 147 |
-{
|
|
| 148 |
- void check_connection_established_dowork(struct context *c); |
|
| 149 |
- |
|
| 150 |
- if (event_timeout_defined(&c->c2.wait_for_connect)) |
|
| 151 |
- {
|
|
| 152 |
- check_connection_established_dowork(c); |
|
| 153 |
- } |
|
| 154 |
-} |
|
| 155 |
- |
|
| 156 |
-/* |
|
| 157 | 142 |
* Should we add routes? |
| 158 | 143 |
*/ |
| 159 | 144 |
static inline void |
| ... | ... |
@@ -437,43 +422,45 @@ check_push_request_dowork(struct context *c) |
| 437 | 437 |
|
| 438 | 438 |
/* |
| 439 | 439 |
* Things that need to happen immediately after connection initiation should go here. |
| 440 |
+ * |
|
| 441 |
+ * Options like --up-delay need to be triggered by this function which |
|
| 442 |
+ * checks for connection establishment. |
|
| 440 | 443 |
*/ |
| 441 | 444 |
void |
| 442 |
-check_connection_established_dowork(struct context *c) |
|
| 445 |
+check_connection_established(struct context *c) |
|
| 443 | 446 |
{
|
| 444 |
- if (event_timeout_trigger(&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) |
|
| 447 |
+ |
|
| 448 |
+ if (CONNECTION_ESTABLISHED(c)) |
|
| 445 | 449 |
{
|
| 446 |
- if (CONNECTION_ESTABLISHED(c)) |
|
| 447 |
- {
|
|
| 448 | 450 |
#if P2MP |
| 449 |
- /* if --pull was specified, send a push request to server */ |
|
| 450 |
- if (c->c2.tls_multi && c->options.pull) |
|
| 451 |
- {
|
|
| 451 |
+ /* if --pull was specified, send a push request to server */ |
|
| 452 |
+ if (c->c2.tls_multi && c->options.pull) |
|
| 453 |
+ {
|
|
| 452 | 454 |
#ifdef ENABLE_MANAGEMENT |
| 453 |
- if (management) |
|
| 454 |
- {
|
|
| 455 |
- management_set_state(management, |
|
| 456 |
- OPENVPN_STATE_GET_CONFIG, |
|
| 457 |
- NULL, |
|
| 458 |
- NULL, |
|
| 459 |
- NULL, |
|
| 460 |
- NULL, |
|
| 461 |
- NULL); |
|
| 462 |
- } |
|
| 463 |
-#endif |
|
| 464 |
- /* fire up push request right away (already 1s delayed) */ |
|
| 465 |
- event_timeout_init(&c->c2.push_request_interval, 0, now); |
|
| 466 |
- reset_coarse_timers(c); |
|
| 467 |
- } |
|
| 468 |
- else |
|
| 469 |
-#endif /* if P2MP */ |
|
| 455 |
+ if (management) |
|
| 470 | 456 |
{
|
| 471 |
- do_up(c, false, 0); |
|
| 457 |
+ management_set_state(management, |
|
| 458 |
+ OPENVPN_STATE_GET_CONFIG, |
|
| 459 |
+ NULL, |
|
| 460 |
+ NULL, |
|
| 461 |
+ NULL, |
|
| 462 |
+ NULL, |
|
| 463 |
+ NULL); |
|
| 472 | 464 |
} |
| 473 |
- |
|
| 474 |
- event_timeout_clear(&c->c2.wait_for_connect); |
|
| 465 |
+#endif |
|
| 466 |
+ /* fire up push request right away (already 1s delayed) */ |
|
| 467 |
+ event_timeout_init(&c->c2.push_request_interval, 0, now); |
|
| 468 |
+ reset_coarse_timers(c); |
|
| 475 | 469 |
} |
| 470 |
+ else |
|
| 471 |
+#endif /* if P2MP */ |
|
| 472 |
+ {
|
|
| 473 |
+ do_up(c, false, 0); |
|
| 474 |
+ } |
|
| 475 |
+ |
|
| 476 |
+ event_timeout_clear(&c->c2.wait_for_connect); |
|
| 476 | 477 |
} |
| 478 |
+ |
|
| 477 | 479 |
} |
| 478 | 480 |
|
| 479 | 481 |
bool |
| ... | ... |
@@ -777,8 +764,10 @@ process_coarse_timers(struct context *c) |
| 777 | 777 |
check_status_file(c); |
| 778 | 778 |
|
| 779 | 779 |
/* process connection establishment items */ |
| 780 |
- check_connection_established(c); |
|
| 781 |
- |
|
| 780 |
+ if (event_timeout_trigger(&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) |
|
| 781 |
+ {
|
|
| 782 |
+ check_connection_established(c); |
|
| 783 |
+ } |
|
| 782 | 784 |
#if P2MP |
| 783 | 785 |
/* see if we should send a push_request in response to --pull */ |
| 784 | 786 |
check_push_request(c); |
| ... | ... |
@@ -88,7 +88,7 @@ void check_fragment_dowork(struct context *c); |
| 88 | 88 |
|
| 89 | 89 |
#endif /* ENABLE_FRAGMENT */ |
| 90 | 90 |
|
| 91 |
-void check_connection_established_dowork(struct context *c); |
|
| 91 |
+void check_connection_established(struct context *c); |
|
| 92 | 92 |
|
| 93 | 93 |
void check_add_routes_dowork(struct context *c); |
| 94 | 94 |
|