

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
2 messages in net.sourceforge.lists.courier-maildropRe: [maildropl] authmysql needs redun...| From | Sent On | Attachments |
|---|---|---|
| web master | Aug 20, 2006 3:26 am | |
| Joseph W. Breu | Sep 1, 2006 2:06 pm | .patch |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [maildropl] authmysql needs redundancy support | Actions... |
|---|---|---|
| From: | Joseph W. Breu (br...@cfu.net) | |
| Date: | Sep 1, 2006 2:06:44 pm | |
| List: | net.sourceforge.lists.courier-maildrop | |
| Attachments: | ||
Quoting web master <caub...@yahoo.ca>:
With today's sql clusters and mulptiple slaves db servers , would it be possible for Mr. Sam or anyone else to add support for multiple target sql servers (defined in MYSQL_SERVER in authmysqlrc file) so that if one fails, the next one is tried ?
This is an issue for courier-authlib. I have a patch for 0.58 (should be portable to newer releases) that adds BACKUP_MYSQL_SERVER config option. If the primary fails, the backup is tried.
Use at your own risk. We have been using this patch for almost 2 years with no ill effects.
Thanks,
--------------------------------------------------------- Joseph W. Breu, CCNA phone : +1.319.268.5228 Senior Network Administrator fax : +1.319.266.8158 Cedar Falls Utilities cell : +1.319.493.1686 support: +1.319.268.5221 url : http://www.cfu.net
--- courier-authlib-0.58.old/authmysqllib.c 2005-07-12 19:54:57.000000000 -0500 +++ courier-authlib-0.58/authmysqllib.c 2006-06-06 10:36:32.225982000 -0500 @@ -113,6 +113,7 @@ static int do_connect() { const char *server; +const char *backup_server; const char *userid; const char *password; const char *database; @@ -147,6 +148,7 @@ }
server=read_env("MYSQL_SERVER");
+ backup_server=read_env("BACKUP_MYSQL_SERVER");
userid=read_env("MYSQL_USERNAME");
password=read_env("MYSQL_PASSWORD");
database=read_env("MYSQL_DATABASE");
@@ -196,11 +198,44 @@
#endif
if (!mysql)
{
- err("failed to connect to mysql server (server=%s, userid=%s): %s",
- server ? server : "<null>",
- userid ? userid : "<null>",
- mysql_error(&mysql_buf));
- return (-1);
+ err("failed to connect to primary mysql server (server=%s, userid=%s):
%s",
+ server ? server : "<null>",
+ userid ? userid : "<null>",
+ mysql_error(&mysql_buf));
+
+ if (backup_server)
+ {
+ /*
+ * If the primary conenction fails, attempt to connect to
+ * the backup server.
+ */
+#if MYSQL_VERSION_ID >= 32200
+ mysql_init(&mysql_buf);
+ mysql=mysql_real_connect(&mysql_buf, backup_server, userid, password,
+ NULL,
+ server_port,
+ server_socket,
+ server_opt);
+#else
+ mysql=mysql_connect(&mysql_buf, backup_server, userid, password);
+#endif
+
+ /*
+ * Test if our connection was a success
+ */
+ if (!mysql)
+ {
+ err("failed to connect to backup mysql server (server=%s, userid=%s):
%s",
+ backup_server ? backup_server : "<null>",
+ userid ? userid : "<null>",
+ mysql_error(&mysql_buf));
+ return (-1);
+ }
+ }
+ else
+ {
+ return (-1);
+ }
}
if (mysql_select_db(mysql, database))








.patch