- /* Skip @first to a non-0-weight target. */
- while (first && ((GSrvTarget *)first->data)->weight == 0)
- first = first->next;
- if (!first)
- break;
-
- /* Skip @last to the last target of the same priority. */
- priority = ((GSrvTarget *)first->data)->priority;
- last = first;
- while (last->next &&
- ((GSrvTarget *)last->next->data)->priority == priority)
- last = last->next;
-
- /* If there's only one non-0 weight target at this priority,
- * we can move on to the next priority level.
- */
- if (last == first)
- continue;
-
- /* Randomly reorder the non-0 weight targets, giving precedence
- * to the ones with higher weight. RFC 2782 describes this in
- * terms of assigning a running sum to each target and building
- * a new list. We do things slightly differently, but should get
- * the same result.
+ priority = ((GSrvTarget *)targets->data)->priority;
+
+ /* Count the number of targets at this priority level, and
+ * compute the sum of their weights.