diff --git a/examples/server_example_logging/CMakeLists.txt b/examples/server_example_logging/CMakeLists.txt index 598cfaef..b886461e 100644 --- a/examples/server_example_logging/CMakeLists.txt +++ b/examples/server_example_logging/CMakeLists.txt @@ -1,5 +1,5 @@ -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/sqlite/sqlite3.h") +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../third_party/sqlite/sqlite3.h") message("Found sqlite source code -> compile sqlite-log driver with static sqlite library") include_directories( @@ -10,11 +10,11 @@ include_directories( set(server_example_SRCS server_example_logging.c static_model.c - ${CMAKE_SOURCE_DIR}/src/logging/drivers/sqlite/log_storage_sqlite.c + ${CMAKE_CURRENT_LIST_DIR}/../../src/logging/drivers/sqlite/log_storage_sqlite.c ) set(sqlite_SRCS - ${CMAKE_SOURCE_DIR}/third_party/sqlite/sqlite3.c + ${CMAKE_CURRENT_LIST_DIR}/../../third_party/sqlite/sqlite3.c ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION") diff --git a/src/mms/iso_client/iso_client_connection.c b/src/mms/iso_client/iso_client_connection.c index 72a203e2..e9fd7c35 100644 --- a/src/mms/iso_client/iso_client_connection.c +++ b/src/mms/iso_client/iso_client_connection.c @@ -636,17 +636,21 @@ IsoClientConnection_handleConnection(IsoClientConnection self) bool IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTimeoutInMs) { + Semaphore_wait(self->tickMutex); + + /* Create socket and start connect */ + self->socket = TcpSocket_create(); - if (self->socket == NULL) + if (self->socket == NULL) { + Semaphore_post(self->tickMutex); return false; + } bool success = true; - /* Create socket and start connect */ setState(self, STATE_CONNECTING); - - Semaphore_wait(self->tickMutex); + setIntState(self, INT_STATE_TCP_CONNECTING); #if (CONFIG_ACTIVATE_TCP_KEEPALIVE == 1) Socket_activateTcpKeepAlive(self->socket, @@ -655,8 +659,6 @@ IsoClientConnection_associateAsync(IsoClientConnection self, uint32_t connectTim CONFIG_TCP_KEEPALIVE_CNT); #endif - setIntState(self, INT_STATE_TCP_CONNECTING); - /* set timeout for connect */ self->nextReadTimeout = Hal_getTimeInMs() + connectTimeoutInMs;