|
Lines 224-229
Link Here
|
| 224 |
struct policyqueue *aio_dstpolicy; |
224 |
struct policyqueue *aio_dstpolicy; |
| 225 |
struct addrinfo *aio_ai; |
225 |
struct addrinfo *aio_ai; |
| 226 |
int aio_matchlen; |
226 |
int aio_matchlen; |
|
|
227 |
int aio_initial_sequence; |
| 227 |
}; |
228 |
}; |
| 228 |
|
229 |
|
| 229 |
static const ns_src default_dns_files[] = { |
230 |
static const ns_src default_dns_files[] = { |
|
Lines 708-713
Link Here
|
| 708 |
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr, |
709 |
aio[i].aio_dstpolicy = match_addrselectpolicy(ai->ai_addr, |
| 709 |
&policyhead); |
710 |
&policyhead); |
| 710 |
set_source(&aio[i], &policyhead); |
711 |
set_source(&aio[i], &policyhead); |
|
|
712 |
aio[i].aio_initial_sequence = i; |
| 711 |
} |
713 |
} |
| 712 |
|
714 |
|
| 713 |
/* perform sorting. */ |
715 |
/* perform sorting. */ |
|
Lines 1066-1071
Link Here
|
| 1066 |
} |
1068 |
} |
| 1067 |
|
1069 |
|
| 1068 |
/* Rule 10: Otherwise, leave the order unchanged. */ |
1070 |
/* Rule 10: Otherwise, leave the order unchanged. */ |
|
|
1071 |
|
| 1072 |
/* |
| 1073 |
* Note that qsort is unstable; so, we can't return zero and |
| 1074 |
* expect the order to be unchanged. |
| 1075 |
* That also means we can't depend on the current position of |
| 1076 |
* dst2 being after dst1. We must enforce the initial order |
| 1077 |
* with an explicit compare on the original position. |
| 1078 |
* The qsort specification requires that "When the same objects |
| 1079 |
* (consisting of width bytes, irrespective of their current |
| 1080 |
* positions in the array) are passed more than once to the |
| 1081 |
* comparison function, the results shall be consistent with one |
| 1082 |
* another." |
| 1083 |
* In other words, If A < B, then we must also return B > A. |
| 1084 |
*/ |
| 1085 |
if (dst2->aio_initial_sequence < dst1->aio_initial_sequence) |
| 1086 |
return(1); |
| 1087 |
|
| 1069 |
return(-1); |
1088 |
return(-1); |
| 1070 |
} |
1089 |
} |
| 1071 |
|
1090 |
|