diff --git a/src/nopoll_helpers.c b/src/nopoll_helpers.c index 524cc67..df32465 100644 --- a/src/nopoll_helpers.c +++ b/src/nopoll_helpers.c @@ -74,26 +74,34 @@ void sendMessage(noPollConn *conn, void *msg, size_t len) { ParodusError("Failed to send msg upstream as connection is not OK\n"); OnboardLog("Failed to send msg upstream as connection is not OK\n"); - if (connErr == 0) - { - getCurrentTime(connStuck_startPtr); - ParodusInfo("Conn got stuck, initialized the first timer\n"); - connErr = 1; - } - else - { - getCurrentTime(connStuck_endPtr); - timeDiff = timeValDiff(connStuck_startPtr, connStuck_endPtr); - ParodusPrint("checking timeout difference:%ld\n", timeDiff); - if( timeDiff >= (10*60*1000)) + if(get_interface_down_event()) + { + ParodusError("Unable to connect to server since interface is down\n"); + } + else + { + if (connErr == 0) { - ParodusError("conn got stuck for over 10 minutes; crashing service.\n"); - OnboardLog("conn got stuck for over 10 minutes; crashing service.\n"); - kill(getpid(),SIGTERM); + getCurrentTime(connStuck_startPtr); + ParodusInfo("Conn got stuck, initialized the first timer\n"); + connErr = 1; } + else + { + getCurrentTime(connStuck_endPtr); + timeDiff = timeValDiff(connStuck_startPtr, connStuck_endPtr); + ParodusPrint("checking timeout difference:%ld\n", timeDiff); - } + if( timeDiff >= (10*60*1000)) + { + ParodusError("conn got stuck for over 10 minutes; crashing service.\n"); + OnboardLog("conn got stuck for over 10 minutes; crashing service.\n"); + kill(getpid(),SIGTERM); + } + + } + } } } diff --git a/tests/test_nopoll_helpers.c b/tests/test_nopoll_helpers.c index e3b4254..663972d 100644 --- a/tests/test_nopoll_helpers.c +++ b/tests/test_nopoll_helpers.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -116,6 +117,11 @@ int kill(pid_t pid, int sig) return (int) mock(); } +bool get_interface_down_event() +{ + return false; +} + /*----------------------------------------------------------------------------*/ /* Tests */ /*----------------------------------------------------------------------------*/