summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaribe 1999 <caribe@users.noreply.github.com>2018-01-03 11:27:20 +0100
committerAnel Husakovic <anel@mariadb.org>2019-09-20 01:36:06 -0700
commit9611d7e08a9f69cd91dfa3b313c5ed1c324121d5 (patch)
tree767680d50dec8d12c62408d88fd632523f131c05
parent75bcf1f9ad4a4bb5fa9cb8818abe6ace52e53d85 (diff)
downloadmariadb-git-9611d7e08a9f69cd91dfa3b313c5ed1c324121d5.tar.gz
Fix
There's an annoying bug that prevents a Sphinx table to connect to a searchd using a host name. So the example table in the documentation https://mariadb.com/kb/en/library/about-sphinxse/#basic-usage that point's to "localhost" actually doesn't work. After some investigation I found two errors. The first one is a wrong check after the getaddrinfo call. The second is a wrong usage of the returned struct.
-rw-r--r--storage/sphinx/ha_sphinx.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc
index 65ad286f5d9..67bf0744c78 100644
--- a/storage/sphinx/ha_sphinx.cc
+++ b/storage/sphinx/ha_sphinx.cc
@@ -2162,7 +2162,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
#if MYSQL_VERSION_ID>=50515
struct addrinfo *hp = NULL;
tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp );
- if ( !tmp_errno || !hp || !hp->ai_addr )
+ if ( tmp_errno || !hp || !hp->ai_addr )
{
bError = true;
if ( hp )
@@ -2189,8 +2189,9 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort )
}
#if MYSQL_VERSION_ID>=50515
- memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) );
- freeaddrinfo ( hp );
+ struct sockaddr_in *in = (sockaddr_in *)hp->ai_addr;
+ memcpy ( &sin.sin_addr, &in->sin_addr, Min ( sizeof(sin.sin_addr), sizeof(in->sin_addr) ) );
+ freeaddrinfo ( hp );
#else
memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) );
my_gethostbyname_r_free();