Permalink
Browse files

mnet: auth/mnet cron() now clears out stale sessions -- how did we mi…

…ss this?
  • Loading branch information...
1 parent 4e04772 commit 4c1c5d2638747cdbfd6c449873831045d2086547 martinlanghoff committed Jan 24, 2007
Showing with 17 additions and 2 deletions.
  1. +17 −2 auth/mnet/auth.php
View
@@ -986,7 +986,17 @@ function keepalive_server($array) {
* @return void
*/
function cron() {
+
+ // run the keepalive client
$this->keepalive_client();
+
+ // admin/cron.php should have run srand for us
+ $random100 = rand(0,100);
+ if ($random100 < 10) { // Approximately 10% of the time.
+ // nuke olden sessions
+ $longtime = $timenow - (1 * 3600 * 24);
+ delete_records_select('mnet_session', "expires < $timenow");
+ }
}
/**
@@ -1033,7 +1043,10 @@ function kill_parent($username, $useragent) {
$mnetsessions = get_records_sql($sql);
- $ignore = delete_records('mnet_session', 'username', $username, 'useragent', $useragent, 'mnethostid', $USER->mnethostid);
+ $ignore = delete_records('mnet_session',
+ 'username', $username,
+ 'useragent', $useragent,
+ 'mnethostid', $USER->mnethostid);
if (false != $mnetsessions) {
$mnet_peer = new mnet_peer();
@@ -1113,7 +1126,9 @@ function kill_children($username, $useragent) {
}
}
- $ignore = delete_records('mnet_session', 'useragent', $useragent, 'userid', $userid);
+ $ignore = delete_records('mnet_session',
+ 'useragent', $useragent,
+ 'userid', $userid);
if (isset($MNET_REMOTE_CLIENT) && isset($MNET_REMOTE_CLIENT->id)) {
$start = ob_start();

0 comments on commit 4c1c5d2

Please sign in to comment.