!159 创建domain socket时,不依赖PGHOST变量来创建socket file的路径

Merge pull request !159 from scarbor_fair/master
This commit is contained in:
opengauss-bot
2020-08-31 20:50:34 +08:00
committed by Gitee
2 changed files with 2 additions and 19 deletions

View File

@ -1219,19 +1219,10 @@ static void CreateLockFile(const char* file_name, bool am_post_master, bool is_d
* the datadir lockfile later.
*/
char* unix_socket_dir = NULL;
char* pg_host = gs_getenv_r("PGHOST");
if (pg_host != NULL) {
check_backend_env(pg_host);
}
if (*g_instance.attr.attr_network.UnixSocketDir != '\0') {
unix_socket_dir = g_instance.attr.attr_network.UnixSocketDir;
} else {
if (pg_host != NULL && *(pg_host) != '\0') {
unix_socket_dir = pg_host;
} else {
unix_socket_dir = DEFAULT_PGSOCKET_DIR;
}
unix_socket_dir = DEFAULT_PGSOCKET_DIR;
}
int rc = snprintf_s(buffer,

View File

@ -67,18 +67,10 @@ extern const char* check_client_env(const char* input_env_value);
do { \
int rc = 0; \
const char* unixSocketDir = NULL; \
const char* pghost = gs_getenv_r("PGHOST"); \
if (check_client_env(pghost) == NULL) { \
pghost = NULL; \
} \
if (sockdir != NULL && (*sockdir) != '\0') { \
unixSocketDir = sockdir; \
} else { \
if (pghost != NULL && (*pghost) != '\0') { \
unixSocketDir = pghost; \
} else { \
unixSocketDir = DEFAULT_PGSOCKET_DIR; \
} \
unixSocketDir = DEFAULT_PGSOCKET_DIR; \
} \
rc = snprintf_s(path, sizeof(path), sizeof(path) - 1, "%s/.s.PGSQL.%d", unixSocketDir, (port)); \
securec_check_ss_c(rc, "\0", "\0"); \