Skip to content
Snippets Groups Projects
Commit c2956e1e authored by Dmitry Simonenko's avatar Dmitry Simonenko
Browse files

lua-socket-fix: fix for address resolving to localhost

it's uncertain which address bind/connect will choose when
connection to localhost. The problem is with /etc/hosts
which can contain bindings for both 127.0.0.1 and ::1 for
localhost (and some system don't).

See for futher explanation:
http://sourceware.org/bugzilla/show_bug.cgi?id=4980
parent 1c66ef10
No related branches found
No related tags found
No related merge requests found
......@@ -817,7 +817,7 @@ lua s:error()
lua s:close()
---
...
lua type(s:bind('localhost', '30303'))
lua type(s:bind('127.0.0.1', '30303'))
---
- userdata
...
......@@ -853,7 +853,7 @@ ping
lua s = box.socket.udp()
---
...
lua type(s:sendto('ping', 'localhost', '30302'))
lua type(s:sendto('ping', '127.0.0.1', '30302'))
---
- number
...
......@@ -876,7 +876,7 @@ lua s:close()
lua s = box.socket.udp()
---
...
lua type(s:bind('localhost', '30301'))
lua type(s:bind('127.0.0.1', '30301'))
---
- userdata
...
......
......@@ -441,12 +441,12 @@ exec admin "lua s:close()"
# connect from test to echo server implemented in
# stored procedure and do send/recv.
#
exec admin "lua type(s:bind('localhost', '30303'))"
exec admin "lua type(s:bind('127.0.0.1', '30303'))"
exec admin "lua type(s:listen())"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.connect(('localhost', 30303))
s.connect(('127.0.0.1', 30303))
s.sendall('ping')
exec admin "lua client, status, addr = s:accept()"
......@@ -472,7 +472,7 @@ s.bind(('localhost', 30302))
# SOCK_DGRAM
exec admin "lua s = box.socket.udp()"
exec admin "lua type(s:sendto('ping', 'localhost', '30302'))"
exec admin "lua type(s:sendto('ping', '127.0.0.1', '30302'))"
exec admin "lua s:error()"
data, addr = s.recvfrom(4)
......@@ -490,7 +490,7 @@ exec admin "lua s:close()"
# stored procedure and do send/recv.
#
exec admin "lua s = box.socket.udp()"
exec admin "lua type(s:bind('localhost', '30301'))"
exec admin "lua type(s:bind('127.0.0.1', '30301'))"
exec admin "lua s:error()"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment