diff options
author | Renato Botelho <renato@netgate.com> | 2017-01-11 09:31:55 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-11 09:31:55 -0200 |
commit | 92838b02b696c8fcd4059f107ae04656ab2f5c42 (patch) | |
tree | f852e018c821ba778c4a15311ec68677c8601bfd | |
parent | f06f9dab79872cb4c08e8aeeab9ccb3de334df65 (diff) | |
parent | 47f967856ef25557d87430026e8b208a8852381f (diff) | |
download | pfsense-92838b02b696c8fcd4059f107ae04656ab2f5c42.zip pfsense-92838b02b696c8fcd4059f107ae04656ab2f5c42.tar.gz |
Merge pull request #3360 from plumbeo/faster-disconnect-all
-rw-r--r-- | src/etc/inc/captiveportal.inc | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc index 449d75c..bc192eb 100644 --- a/src/etc/inc/captiveportal.inc +++ b/src/etc/inc/captiveportal.inc @@ -1082,35 +1082,31 @@ function captiveportal_disconnect_all($term_cause = 6, $logoutReason = "DISCONNE global $g, $config, $cpzone, $cpzoneid; /* check if we're pruning old entries and eventually wait */ - $rcprunelock = try_lock("rcprunecaptiveportal{$cpzone}", 60); + $rcprunelock = try_lock("rcprunecaptiveportal{$cpzone}", 15); /* if we still don't have the lock, unlock forcefully and take it */ if (!$rcprunelock) { - log_error("CP zone ${cpzone}: could not obtain the lock for more than 60 seconds, lock taken forcefully to disconnect all users"); + log_error("CP zone ${cpzone}: could not obtain the lock for more than 15 seconds, lock taken forcefully to disconnect all users"); unlock_force("rcprunecaptiveportal{$cpzone}"); $rcprunelock = lock("rcprunecaptiveportal{$cpzone}", LOCK_EX); } - $radiussrvs = captiveportal_get_radius_servers(); - $cpdb = captiveportal_read_db(); + /* take a lock so new users won't be able to log in */ + $cpdblck = lock("captiveportaldb{$cpzone}", LOCK_EX); + + captiveportal_radius_stop_all($term_cause, $logoutReason); - /* remove immediately the active users from the database to avoid races */ + /* remove users from the database */ + $cpdb = captiveportal_read_db(); $unsetindexes = array_column($cpdb,5); if (!empty($unsetindexes)) { captiveportal_remove_entries($unsetindexes); } - foreach ($cpdb as $cpentry) { - if (empty($cpentry[11])) { - $cpentry[11] = 'first'; - } - $radiusservers = $radiussrvs[$cpentry[11]]; - - captiveportal_disconnect($cpentry, $radiusservers, $term_cause); - captiveportal_logportalauth($cpentry[4], $cpentry[3], $cpentry[2], $logoutReason); - } - unset($cpdb); + /* reinit ipfw rules */ + captiveportal_init_rules(true); + unlock($cpdblck); unlock($rcprunelock); } |