[tarantool-patches] [PATCH v2] iproto: close socket explicitly before wal_dir at exit
Vladimir Davydov
vdavydov.dev at gmail.com
Mon Feb 25 20:08:29 MSK 2019
On Mon, Feb 25, 2019 at 07:50:47PM +0300, Konstantin Osipov wrote:
> * Ilya Kosarev <i.kosarev at tarantool.org> [19/02/25 19:14]:
> > +void
> > +iproto_free()
> > +{
> > + tt_pthread_cancel(net_cord.id);
> > + tt_pthread_join(net_cord.id, NULL);
> > + /*
> > + * Close socket descriptor to prevent hot standby instance
> > + * failing to bind in case it tries to bind
> > + * before socket is closed by OS.
> > + */
> > + close(binary.ev.fd);
> > +}
>
> What if there is no socket descriptor in binary.ev.fd?
> I understand it's OK to close a non-existing descriptor, but still
> looks a bit messy to me.
Yeah, missed that, sorry. Fixed as shown below:
>From 37b883145ff0464640d917fe58b488eb7d539400 Mon Sep 17 00:00:00 2001
From: Vladimir Davydov <vdavydov.dev at gmail.com>
Date: Mon, 25 Feb 2019 20:03:27 +0300
Subject: [PATCH] iproto: don't attempt to close socket if it was not open
This can't entail any consequences, because socket fd is set to -1 in
this case, but this just looks a bit messy. Let's clean it up.
Follow-up commit 305dbcf68953 ("iproto: close socket explicitly before
wal_dir at exit").
diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 226b9d06..863eb4f0 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -2152,5 +2152,6 @@ iproto_free()
* failing to bind in case it tries to bind before socket
* is closed by OS.
*/
- close(binary.ev.fd);
+ if (evio_service_is_active(&binary))
+ close(binary.ev.fd);
}
More information about the Tarantool-patches
mailing list