Make non blocking BCM socket.
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 10 May 2017 07:51:09 +0000 (09:51 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Wed, 10 May 2017 16:45:55 +0000 (18:45 +0200)
Needed because we use systemd event loop that recommend that.

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

index b0148d9..7323565 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <net/if.h>
 #include <sys/ioctl.h>
+#include <fcntl.h>
 
 namespace utils
 {
@@ -58,6 +59,8 @@ namespace utils
                                ERROR(binder_interface, "%s: Connect failed. %s", __FUNCTION__, strerror(errno));
                                close();
                        }
+                       // Needed because of using systemD event loop. See sd_event_add_io manual.
+                       fcntl(socketcan_t::socket_, F_SETFL, O_NONBLOCK);
                }
                return socket_;
        }