From 569e3ad1ead6469fa9019a399dcef8d4f2fb71b4 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 11 May 2018 14:20:22 +0400 Subject: MDEV-15655: Add Linux abstract socket support Less ifdefs, disable main.connect-abstract until libmariadb is updated. --- mysql-test/main/disabled.def | 1 + sql/mysqld.cc | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def index b489139a59f..e83ff00d10b 100644 --- a/mysql-test/main/disabled.def +++ b/mysql-test/main/disabled.def @@ -21,3 +21,4 @@ innodb-wl5522-debug-zip : broken upstream innodb_bug12902967 : broken upstream file_contents : MDEV-6526 these files are not installed anymore max_statement_time : cannot possibly work, depends on timing +connect-abstract : waiting for libmariadb update diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 716bd472934..4309748fe06 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2787,7 +2787,7 @@ static void network_init(void) size_t port_len; DBUG_PRINT("general",("UNIX Socket is %s",mysqld_unix_port)); - if ((port_len=strlen(mysqld_unix_port)) > (sizeof(UNIXaddr.sun_path) - 1)) + if ((port_len= strlen(mysqld_unix_port)) > sizeof(UNIXaddr.sun_path) - 1) { sql_print_error("The socket file path is too long (> %u): %s", (uint) sizeof(UNIXaddr.sun_path) - 1, mysqld_unix_port); @@ -2808,22 +2808,23 @@ static void network_init(void) #if defined(__linux__) /* Abstract socket */ if (mysqld_unix_port[0] == '@') + { UNIXaddr.sun_path[0]= '\0'; + port_len+= offsetof(struct sockaddr_un, sun_path); + } else #endif + { (void) unlink(mysqld_unix_port); + port_len= sizeof(UNIXaddr); + } arg= 1; (void) mysql_socket_setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR, (char*)&arg, sizeof(arg)); umask(0); if (mysql_socket_bind(unix_sock, reinterpret_cast(&UNIXaddr), -#if defined(__linux__) - offsetof(struct sockaddr_un, sun_path) + port_len -#else - sizeof(UNIXaddr) -#endif - ) < 0) + port_len) < 0) { sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */ sql_print_error("Do you already have another mysqld server running on socket: %s ?",mysqld_unix_port); -- cgit v1.2.1