Commit 4a3b1cfc authored by Mike Hibler's avatar Mike Hibler

Make the available uid lookup more efficient.

Hopefully will prevent catastrophic DB failure as we no longer make
tens of thousands of DB queries to find the first available uid.
parent e95baf08
......@@ -531,7 +531,7 @@ sub Create($$$$)
" u.unix_uid + 1 = r.unix_uid ".
"where u.unix_uid>=$min_uid and ".
" u.unix_uid<60000 and ".
" r.unix_uid is null limit 1");
" r.unix_uid is null order by u.unix_uid limit 1");
goto bad
if (! $query_result);
......@@ -543,8 +543,8 @@ sub Create($$$$)
my ($unused) = $query_result->fetchrow_array();
if (getpwuid($unused)) {
# Keep going.
$min_uid++;
# Keep going from this one.
$min_uid = $unused + 1;
}
else {
# Break out of loop.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment