projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a5f8ee6
)
* serv_smtp.c: when multiple MX's are the same preference, randomize them
author
Art Cancro
<ajc@citadel.org>
Sat, 1 Dec 2001 17:00:23 +0000
(17:00 +0000)
committer
Art Cancro
<ajc@citadel.org>
Sat, 1 Dec 2001 17:00:23 +0000
(17:00 +0000)
citadel/ChangeLog
patch
|
blob
|
history
citadel/domain.c
patch
|
blob
|
history
diff --git
a/citadel/ChangeLog
b/citadel/ChangeLog
index 713cc019cc471d1bb0c371ec281567356d868270..559e733df3ed9a58e2d0c73ed5af0ee80ce14a6e 100644
(file)
--- a/
citadel/ChangeLog
+++ b/
citadel/ChangeLog
@@
-1,4
+1,7
@@
$Log$
$Log$
+ Revision 580.82 2001/12/01 17:00:23 ajc
+ * serv_smtp.c: when multiple MX's are the same preference, randomize them
+
Revision 580.81 2001/12/01 07:18:28 ajc
* Fixed an SMTP delivery problem that was causing certain classes of
transient errors to cause a message to never be delivered.
Revision 580.81 2001/12/01 07:18:28 ajc
* Fixed an SMTP delivery problem that was causing certain classes of
transient errors to cause a message to never be delivered.
@@
-2886,3
+2889,4
@@
Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
diff --git
a/citadel/domain.c
b/citadel/domain.c
index 69376cbb0b5d16a541c47479917a3b1725704f10..f64458ed408f303b6a42486475bff619cba072b6 100644
(file)
--- a/
citadel/domain.c
+++ b/
citadel/domain.c
@@
-52,6
+52,22
@@
int get_smarthosts(char *mxbuf) {
}
}
+/*
+ * Compare the preference of two MX records. First check by the actual
+ * number listed in the MX record. If they're identical, randomize the
+ * result.
+ */
+inline int mx_compare_pref(int pref1, int pref2) {
+ if (pref1 > pref2) {
+ return(1);
+ }
+ else if (pref1 < pref2) {
+ return(1);
+ }
+ else {
+ return(rand() % 2);
+ }
+}
/*
/*
@@
-69,8
+85,7
@@
void sort_mxrecs(struct mx *mxrecs, int num_mxrecs) {
/* do the sort */
for (a = num_mxrecs - 2; a >= 0; --a) {
for (b = 0; b <= a; ++b) {
/* do the sort */
for (a = num_mxrecs - 2; a >= 0; --a) {
for (b = 0; b <= a; ++b) {
- if (mxrecs[b].pref > mxrecs[b+1].pref) {
-
+ if (mx_compare_pref(mxrecs[b].pref,mxrecs[b+1].pref)) {
memcpy(&hold1, &mxrecs[b], sizeof(struct mx));
memcpy(&hold2, &mxrecs[b+1], sizeof(struct mx));
memcpy(&mxrecs[b], &hold2, sizeof(struct mx));
memcpy(&hold1, &mxrecs[b], sizeof(struct mx));
memcpy(&hold2, &mxrecs[b+1], sizeof(struct mx));
memcpy(&mxrecs[b], &hold2, sizeof(struct mx));