Project

General

Profile

« Previous | Next » 

Revision 8171a2c2

Added by Ermal LUÇI almost 12 years ago

Introduce two new functions to be used on locking.

- try_lock: used for trying to get an EXCLUSIVE lock for a specified timeout by default of 5
- unlock_force: which just releases any locks held on a specified lock

Use this new functions on rc.openvpn to avoid spurious stale locks around.

View differences:

etc/rc.openvpn
80 80
} else
81 81
	return;
82 82

  
83
$openvpnlck = lock('openvpn', LOCK_EX);
83
$openvpnlck = try_lock('openvpn', 10);
84
if (!$openvpnlck) {
85
	log_error(gettext("Could not obtain openvpn lock for executing rc.openvpn for more than 10 seconds continuing..."));
86
	unlock_force('openvpn');
87
	$openvpnlck = lock('openvpn', LOCK_EX);
88
}
89

  
84 90
$arg_array = explode(",",$argument);
85 91
foreach ($arg_array as $arg_element) {
86 92
	$gwgroups = array();

Also available in: Unified diff