On Wed, Sep 7, 2016 at 7:26 PM, Victor Wagner <vi...@wagner.pp.ru> wrote: > No, algorithm here is more complicated. It must ensure that there would > not be second attempt to connect to host, for which unsuccessful > connection attempt was done. So, there is list rearrangement. >Algorithm for pick random list element by single pass is quite trivial.
If concern is only about excluding address which was tried previously. Then I think we can try this way, randomly permute given address list (for example fisher-yates shuffle) before trying any of those address in it. After that you can treat the new list exactly like we do for sequential connections. I think this makes code less complex. -- Thanks and Regards Mithun C Y EnterpriseDB: http://www.enterprisedb.com