]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Move openvpn_sleep() to manage.c
authorSteffan Karger <steffan.karger@fox-it.com>
Thu, 20 Jul 2017 16:00:35 +0000 (18:00 +0200)
committerGert Doering <gert@greenie.muc.de>
Thu, 20 Jul 2017 18:19:49 +0000 (20:19 +0200)
openvpn_sleep() is basically "service the management interface for x
seconds, then return".  Therefore, manage.c is a more suitable location
than the random collection of unrelated stuff called misc.c.

(I think we should find a better place for everything currently in misc.c,
and get rid of it all together.  This patch is part of that effort.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1500566435-29920-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15109.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/forward.c
src/openvpn/init.c
src/openvpn/manage.c
src/openvpn/manage.h
src/openvpn/misc.c
src/openvpn/misc.h
src/openvpn/socket.c

index 371ddca58495ff3e4315ba390b977dc944b4545f..c45d1259c4319099113078165e67ef6d784e6a1b 100644 (file)
@@ -756,7 +756,7 @@ read_incoming_link(struct context *c)
                 if (event_timeout_defined(&c->c2.explicit_exit_notification_interval))
                 {
                     msg(D_STREAM_ERRORS, "Connection reset during exit notification period, ignoring [%d]", status);
-                    openvpn_sleep(1);
+                    management_sleep(1);
                 }
                 else
 #endif
index a54307ad33b36129b33ab010a130e8f255b8c81a..bc3b81e35a7ec35a3b4bcdbc168fbbd1e2a9412a 100644 (file)
@@ -1969,7 +1969,7 @@ do_up(struct context *c, bool pulled_options, unsigned int option_types_found)
                 /* if so, close tun, delete routes, then reinitialize tun and add routes */
                 msg(M_INFO, "NOTE: Pulled options changed on restart, will need to close and reopen TUN/TAP device.");
                 do_close_tun(c, true);
-                openvpn_sleep(1);
+                management_sleep(1);
                 c->c2.did_open_tun = do_open_tun(c);
                 update_time();
             }
@@ -2263,7 +2263,7 @@ socket_restart_pause(struct context *c)
     if (sec)
     {
         msg(D_RESTART, "Restart pause, %d second(s)", sec);
-        openvpn_sleep(sec);
+        management_sleep(sec);
     }
 }
 
index 2b85d25cc8145c9b1fa4435be167eb452c36aaac..13be6f6d7af760183347ea1861dd58d58c705417 100644 (file)
@@ -3997,9 +3997,25 @@ log_history_ref(const struct log_history *h, const int index)
     }
 }
 
+void
+management_sleep(const int n)
+{
+    if (management)
+    {
+        management_event_loop_n_seconds(management, n);
+    }
+    else
+    {
+        sleep(n);
+    }
+}
+
 #else  /* ifdef ENABLE_MANAGEMENT */
-static void
-dummy(void)
+
+void
+management_sleep(const int n)
 {
+    sleep(n);
 }
+
 #endif /* ENABLE_MANAGEMENT */
index 542cc07a0d34382bd45e8191fc8558adc6f7c707..676be640e54e06d6bfa09872eb1a16d9545c9597 100644 (file)
@@ -605,4 +605,11 @@ management_bytes_server(struct management *man,
 #endif /* MANAGEMENT_DEF_AUTH */
 
 #endif /* ifdef ENABLE_MANAGEMENT */
+
+/**
+ * A sleep function that services the management layer for n seconds rather
+ * than doing nothing.
+ */
+void management_sleep(const int n);
+
 #endif /* ifndef MANAGE_H */
index f6d6c6ad6c632198c0166edb7f4205460defb918..ae96aa690258cb127a30df11f5267d12de965ab3 100644 (file)
@@ -1615,19 +1615,6 @@ make_extended_arg_array(char **p, struct gc_arena *gc)
     }
 }
 
-void
-openvpn_sleep(const int n)
-{
-#ifdef ENABLE_MANAGEMENT
-    if (management)
-    {
-        management_event_loop_n_seconds(management, n);
-        return;
-    }
-#endif
-    sleep(n);
-}
-
 /*
  * Remove security-sensitive strings from control message
  * so that they will not be output to log file.
index bc267d73fc6fe5e258e06ff92e7b4692971ae294..32b64e8bb15c2629b0f711d955f9dbf0af6c5e46 100644 (file)
@@ -292,12 +292,6 @@ bool env_safe_to_print(const char *str);
 /* returns true if environmental variable may be passed to an external program */
 bool env_allowed(const char *str);
 
-/*
- * A sleep function that services the management layer for n
- * seconds rather than doing nothing.
- */
-void openvpn_sleep(const int n);
-
 void configure_path(void);
 
 const char *sanitize_control_message(const char *str, struct gc_arena *gc);
index 846df04beb987626157b9109293a6e5f7f29780c..6e01fe10959d1303b3dec7010022d157d5be38f1 100644 (file)
@@ -496,7 +496,7 @@ openvpn_getaddrinfo(unsigned int flags,
                 goto done;
             }
 
-            openvpn_sleep(fail_wait_interval);
+            management_sleep(fail_wait_interval);
         }
 
         ASSERT(res);
@@ -1193,7 +1193,7 @@ socket_listen_accept(socket_descriptor_t sd,
 
         if (status <= 0)
         {
-            openvpn_sleep(1);
+            management_sleep(1);
             continue;
         }
 
@@ -1228,7 +1228,7 @@ socket_listen_accept(socket_descriptor_t sd,
                 break;
             }
         }
-        openvpn_sleep(1);
+        management_sleep(1);
     }
 
     if (!nowait && openvpn_close_socket(sd))
@@ -1374,7 +1374,7 @@ openvpn_connect(socket_descriptor_t sd,
 #endif
                     break;
                 }
-                openvpn_sleep(1);
+                management_sleep(1);
                 continue;
             }