[Tarantool-patches] [PATCH v1 3/4] test: enable SO_REUSEADDR on socket in httpd.py
Leonid Vasiliev
lvasiliev at tarantool.org
Thu Jan 14 12:09:34 MSK 2021
Hi! Thank you for the patch.
LGTM.
This is a popular technique.
But I don't understand:"Why is it needed when python3 is used, but not
needed for python2?" If you know, share with me, if not, let it remain a
mystery.
On 13.01.2021 11:48, sergeyb at tarantool.org wrote:
> From: Sergey Bronnikov <sergeyb at tarantool.org>
>
> TL;DR httpd.py warns that port is busy when restart server. With socket
> option SO_REUSEADDR it allows to restart httpd.py without problem.
>
> Socket option SO_REUSEADDR tells the kernel that even if this port is
> busy, go ahead and reuse it anyway. If it is busy, but with another
> state, you will still get an address already in use error. It is useful
> if your server has been shut down, and then restarted right away while
> sockets are still active on its port.
> ---
> test/app-tap/httpd.py | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/test/app-tap/httpd.py b/test/app-tap/httpd.py
> index 62435e91a..60084bdbf 100755
> --- a/test/app-tap/httpd.py
> +++ b/test/app-tap/httpd.py
> @@ -138,6 +138,7 @@ else:
> usage()
>
> sock = socket.socket(sock_family, socket.SOCK_STREAM)
> +sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
> sock.bind(sock_addr)
> sock.listen(10)
>
>
More information about the Tarantool-patches
mailing list