Skip to content
  • Dan Winship's avatar
    Fix multiple bugs in g_srv_target_list_sort() · ce6fbd62
    Dan Winship authored
    In particular, targets with weight 0 should be very UNlikely to be
    selected, not very likely, as they were before. However, even ignoring
    that bug in the logic, there was an additional bug (swapping list
    items would cause the 0-weight items to get re-ordered incorrectly
    anyway), and the code contained several fencepost errors.
    
    This patch also adds gio/tests/srvtarget.c, which confirms that for a
    sample list of targets, we now generate all possible correct random
    sortings and no incorrect sortings, and the correct sortings occur in
    roughly the expected proportions (though if the current code is
    still wrong, those proportions may be wrong as well).
    
    http://bugzilla.gnome.org/show_bug.cgi?id=583398
    ce6fbd62