diff options
author | tnurnberg@mysql.com/sin.intern.azundris.com <> | 2007-09-13 16:19:46 +0200 |
---|---|---|
committer | tnurnberg@mysql.com/sin.intern.azundris.com <> | 2007-09-13 16:19:46 +0200 |
commit | 3c6ca8d6edf55764df93a831f61dc3855e82d91c (patch) | |
tree | 602e3e9d9862d8866b20f7d497d64c91d470ea4e /libmysql | |
parent | 4a52b5c88547a01f33b2566d4503f6eef7f082bc (diff) | |
download | mariadb-git-3c6ca8d6edf55764df93a831f61dc3855e82d91c.tar.gz |
Bug #15327: configure: --with-tcp-port option being partially ignored
make sure that if builder configured with a non-standard (!= 3306)
default TCP port that value actually gets used throughout. if they
didn't configure a value, assume "use a sensible default", which
will be read from /etc/services or, failing that, from the factory
default. That makes the order of preference
- command-line option
- my.cnf, where applicable
- $MYSQL_TCP_PORT environment variable
- /etc/services (unless configured --with-tcp-port)
- default port (--with-tcp-port=... or factory default)
Diffstat (limited to 'libmysql')
-rw-r--r-- | libmysql/libmysql.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 72bc4445d83..5388aa07b9d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -133,10 +133,23 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), { struct servent *serv_ptr; char *env; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); - if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port =(uint) atoi(env); + + /* + if builder specifically requested a default port, use that + (even if it coincides with our factory default). + only if they didn't do we check /etc/services (and, failing + on that, fall back to the factory default of 3306). + either default can be overridden by the environment variable + MYSQL_TCP_PORT, which in turn can be overridden with command + line options. + */ + +#if MYSQL_PORT_DEFAULT == 0 + if ((serv_ptr = getservbyname("mysql", "tcp"))) + mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); +#endif + if ((env = getenv("MYSQL_TCP_PORT"))) + mysql_port =(uint) atoi(env); } #endif } |