Close socket by default when destroying object
authorRomain Forlot <romain.forlot@iot.bzh>
Thu, 1 Jun 2017 13:59:57 +0000 (15:59 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 1 Jun 2017 16:40:13 +0000 (18:40 +0200)
As socket is back to only movable, only one copy of a socket
can be present at a time, so when the object is destroyed we have
to close the socket too.

Change-Id: Id64bb53919ce7c24476c26ba9a8520affa3f6273
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/utils/socketcan.cpp

index 3aa34d2..71588a6 100644 (file)
@@ -45,7 +45,10 @@ namespace utils
        }
 
        socketcan_t::~socketcan_t()
-       {}
+       {
+               close();
+               socket_ = INVALID_SOCKET;
+       }
 
        const struct sockaddr_can& socketcan_t::get_tx_address() const
        {