summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorMatthew Grooms <mgrooms@pfsense.org>2008-09-07 06:43:30 +0000
committerMatthew Grooms <mgrooms@pfsense.org>2008-09-07 06:43:30 +0000
commit705c8ec9fc82f3d6d9fd491278c2789b92b5be32 (patch)
tree612f9b4f8ab988f488beaa3fdfaeefea5fa268a3 /etc
parent3615234313508ce8d8cfabcbb785c7b9f786a738 (diff)
downloadpfsense-705c8ec9fc82f3d6d9fd491278c2789b92b5be32.zip
pfsense-705c8ec9fc82f3d6d9fd491278c2789b92b5be32.tar.gz
When restarting an OpenVPN process, don't send a term signal and expect it
to exit within a fixed time frame of two seconds. The old process may take longer to exit and cause the new process creation to fail. Instead, check the process status every 1/4 seconds and only continue once it terminates.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/openvpn.inc22
1 files changed, 17 insertions, 5 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc
index abc2337..e53aa74 100644
--- a/etc/inc/openvpn.inc
+++ b/etc/inc/openvpn.inc
@@ -482,13 +482,22 @@ function openvpn_restart($mode, & $settings) {
$vpnid = $settings['vpnid'];
$mode_id = $mode.$vpnid;
- $pidfile = $g['varrun_path']."/openvpn_{$mode_id}.pid";
- killbypid($pidfile);
- sleep(2);
+ /* read the pid file */
+ $pfile = $g['varrun_path']."/openvpn_{$mode_id}.pid";
+ $pid = rtrim(file_get_contents($pfile));
+ unlink($pfile);
+
+ /* send the process a term signal */
+ posix_kill($pid, SIGTERM);
+
+ /* wait until the process exits */
+ while(posix_kill($pid, 0))
+ usleep(250000);
if ($settings['disable'])
return;
+ /* start the new process */
$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
mwexec_bg("nohup openvpn --config {$fpath}");
touch("{$g['tmp_path']}/filter_dirty");
@@ -506,11 +515,14 @@ function openvpn_delete($mode, & $settings) {
else
$devname = "ovpnc{$vpnid}";
- /* kill the process */
+ /* read the pid file */
$pfile = "{$g['varrun_path']}/openvpn_{$mode_id}.pid";
- killbypid($pfile);
+ $pid = trim(file_get_contents($pfile));
unlink($pfile);
+ /* send the process a term signal */
+ posix_kill($pid, SIGTERM);
+
/* remove the device from the openvpn group */
mwexec("/sbin/ifconfig {$devname} -group openvpn");
OpenPOWER on IntegriCloud