diff options
author | Jeremy Allison <jra@samba.org> | 2009-04-01 09:16:41 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-04-01 09:16:41 -0700 |
commit | eaddcfef1ba553744ae9293feaf7585ec9aaa0db (patch) | |
tree | 1bfc22bf1e98b279ccf45af0ed065b9afd21fd98 /lib/util | |
parent | 1e742660bf3fed39b7efa2502d88ee6415522385 (diff) | |
parent | 264b28ec0962c355ee90f9ac67fcf07cd84c5c7b (diff) | |
download | samba-eaddcfef1ba553744ae9293feaf7585ec9aaa0db.tar.gz samba-eaddcfef1ba553744ae9293feaf7585ec9aaa0db.tar.bz2 samba-eaddcfef1ba553744ae9293feaf7585ec9aaa0db.zip |
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/idtree.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/util/idtree.c b/lib/util/idtree.c index c8a8b6346a..0af93a229d 100644 --- a/lib/util/idtree.c +++ b/lib/util/idtree.c @@ -372,12 +372,16 @@ _PUBLIC_ int idr_get_new_random(struct idr_context *idp, void *ptr, int limit) /* first try a random starting point in the whole range, and if that fails, then start randomly in the bottom half of the range. This can only - fail if the range is over half full */ + fail if the range is over half full, and finally fallback to any + free id */ id = idr_get_new_above(idp, ptr, 1+(generate_random() % limit), limit); if (id == -1) { id = idr_get_new_above(idp, ptr, 1+(generate_random()%(limit/2)), limit); } - + if (id == -1) { + id = idr_get_new_above(idp, ptr, 1, limit); + } + return id; } |