

![]() | 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-maildrop[maildropl] Mysql patch| From | Sent On | Attachments |
|---|---|---|
| Jeff Williams | Jun 7, 2004 4:48 am | .patch |
| Jeff Williams | Jun 7, 2004 12:31 pm |

![]() | 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: | [maildropl] Mysql patch | Actions... |
|---|---|---|
| From: | Jeff Williams (jef...@globaldial.com) | |
| Date: | Jun 7, 2004 4:48:39 am | |
| List: | net.sourceforge.lists.courier-maildrop | |
| Attachments: | ||
This patch allows you to use a list of comma, space or tab separated hostnames as the hostname argument in the mysql config. The hostnames will be tried in the order given, going to the next hostname on connection failure.
Jeff
diff -ur maildrop-1.6.3.20040424.orig/maildrop/mdmysql.c
maildrop-1.6.3.20040424/maildrop/mdmysql.c
--- maildrop-1.6.3.20040424.orig/maildrop/mdmysql.c Sat Oct 11 11:26:24 2003
+++ maildrop-1.6.3.20040424/maildrop/mdmysql.c Mon Jun 7 19:12:42 2004
@@ -22,15 +22,20 @@
"SELECT %s, %s, %s, %s, %s, %s FROM %s WHERE %s = \"%s\" %s";
char *querybuf;
unsigned int querybuf_len;
+ int i;
-
+ for (i=0; (i<MYSQL_HOSTNAMES && !mysql); i++)
+ {
+ /* break we we hit the NULL hostnames */
+ if (!cfg->hostname[i]) break;
#if MYSQL_VERSION_ID >= 32200
- mysql_init(&mysql_buf);
- mysql=mysql_real_connect(&mysql_buf, cfg->hostname, cfg->dbuser, cfg->dbpw,
+ mysql_init(&mysql_buf);
+ mysql=mysql_real_connect(&mysql_buf, cfg->hostname[i], cfg->dbuser,
cfg->dbpw,
NULL, cfg->port, cfg->socket, 0);
#else
- mysql=mysql_connect(&mysql_buf, server, userid, password);
+ mysql=mysql_connect(&mysql_buf, cfg->hostname[i], cfg->dbuser, cfg->dbpw);
#endif
+ }
if ( !mysql )
return NULL;
diff -ur maildrop-1.6.3.20040424.orig/maildrop/mdmysqlconfig.c
maildrop-1.6.3.20040424/maildrop/mdmysqlconfig.c
--- maildrop-1.6.3.20040424.orig/maildrop/mdmysqlconfig.c Sat Oct 11 11:26:24
2003
+++ maildrop-1.6.3.20040424/maildrop/mdmysqlconfig.c Mon Jun 7 19:23:02 2004
@@ -8,6 +8,7 @@
FILE *fp;
char *buf,*var,*val;
mdmysqlconfig *cfg = NULL;
+ int i;
buf = (char*)malloc(1025); var = (char*)malloc(1025); @@ -17,7 +18,8 @@ if ( fp ) { cfg = (mdmysqlconfig*)malloc(sizeof(mdmysqlconfig)+1); - cfg->hostname = NULL; + for (i=0; i<MYSQL_HOSTNAMES; i++) + cfg->hostname[i] = NULL; cfg->database = NULL; cfg->dbuser = NULL; cfg->dbpw = NULL; @@ -59,7 +61,21 @@ }
if ( !strcasecmp(var,"hostname") )
- cfg->hostname = (char*)strdup(val);
+ {
+ /* allow up to MYSQL_HOSTNAMES comma or space separated hostnames */
+ size_t len = 0;
+ char *cur = val;
+ int i;
+ for (i=0; ((len = strcspn(cur, " ,\t")) && (i<MYSQL_HOSTNAMES)); i++)
+ {
+ strncpy(buf, cur, len);
+ buf[len] = '\0';
+ cfg->hostname[i] = strdup(buf);
+
+ /* find the start of the next tok */
+ cur += len + strspn(cur+len, " ,\t");
+ }
+ }
if ( !strcasecmp(var,"port") )
cfg->port = atoi(val);
if ( !strcasecmp(var,"socket") )
diff -ur maildrop-1.6.3.20040424.orig/maildrop/mdmysqlconfig.h
maildrop-1.6.3.20040424/maildrop/mdmysqlconfig.h
--- maildrop-1.6.3.20040424.orig/maildrop/mdmysqlconfig.h Sat Oct 11 11:26:24
2003
+++ maildrop-1.6.3.20040424/maildrop/mdmysqlconfig.h Mon Jun 7 19:05:25 2004
@@ -17,8 +17,11 @@
#define MYSQL_DEFAULT_WHERE_CLAUSE ""
#define MYSQL_DEFAULT_TIMEOUT 5
+#define MYSQL_HOSTNAMES 5 + typedef struct { - char *hostname; + /* allow some hostname options */ + char *hostname[MYSQL_HOSTNAMES]; unsigned short port; char *socket; char *database;








.patch