diff options
author | Adam <Adam@anope.org> | 2013-10-01 23:48:46 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-10-05 00:33:03 -0400 |
commit | 353ee5cc933b96e92fad807a784ba40505e95a00 (patch) | |
tree | e3cfba4a40cff01e0cc907ff20a0a3638ad3a6c4 | |
parent | b094132c9d1dff2869efd70f3d6f8d1654331780 (diff) |
Fix xline uid generation when the one chosen already exists
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/xline.cpp | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp index dbcdea02c..fae776f9b 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -447,7 +447,7 @@ void Anope::Init(int ac, char **av) /* Initialize random number generator */ block = Config->GetBlock("options"); - srand(block->Get<unsigned>("seed")); + srand(block->Get<unsigned>("seed") ^ time(NULL)); /* load modules */ Log() << "Loading modules..."; diff --git a/src/xline.cpp b/src/xline.cpp index 554632a38..a5087109c 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -220,11 +220,12 @@ Anope::string XLineManager::GenerateUID() { Anope::string id; int count = 0; - while (id.empty() || XLinesByUID->count(id) > 0) + do { + id.clear(); + if (++count > 10) { - id.clear(); Log(LOG_DEBUG) << "Unable to generate XLine UID"; break; } @@ -238,6 +239,7 @@ Anope::string XLineManager::GenerateUID() id += c; } } + while (XLinesByUID->count(id) > 0); return id; } |