Fix build warning with GCC 4.6 when diagnostic is disabled.
Put new handles at the beginning of the shared list: we're likely to open them in each session, so it's better not to search the whole list.