From 1ee784aca5696286f567a4504b22a11cdaa0d0f8 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sat, 22 Apr 2017 13:58:26 +0200 Subject: Fix: opening bcm socket still trying to bind as a RAW socket. Wrong condition testing making connect and bind happens. Change-Id: Ic75a74d044e9763fdf42e50f7643b26ffaf5d76d Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/utils/socket.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'CAN-binder/low-can-binding/utils') diff --git a/CAN-binder/low-can-binding/utils/socket.cpp b/CAN-binder/low-can-binding/utils/socket.cpp index 01937ed4..f4a30111 100644 --- a/CAN-binder/low-can-binding/utils/socket.cpp +++ b/CAN-binder/low-can-binding/utils/socket.cpp @@ -127,10 +127,13 @@ namespace utils txAddress_.can_family = AF_CAN; txAddress_.can_ifindex = ifr.ifr_ifindex; - if(bcm && connect((struct sockaddr *)&txAddress_, sizeof(txAddress_)) < 0) + if(bcm) { - ERROR(binder_interface, "%s: Connect failed. %s", __FUNCTION__, strerror(errno)); - close(); + if(connect((struct sockaddr *)&txAddress_, sizeof(txAddress_)) < 0) + { + ERROR(binder_interface, "%s: Connect failed. %s", __FUNCTION__, strerror(errno)); + close(); + } } // It's a RAW socket request, bind it to txAddress else if(bind((struct sockaddr *)&txAddress_, sizeof(txAddress_)) < 0) -- cgit 1.2.3-korg