Skip to content

Commit

Permalink
fixup! Fix race condition in main loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Sep 4, 2023
1 parent 446521e commit ee03010
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/cloud_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "oc_pki.h"
#include "oc_clock_util.h"
#include "port/oc_assert.h"
#include "util/oc_compiler.h"
#include "util/oc_features.h"
#include "util/oc_process.h"

Expand Down Expand Up @@ -119,7 +120,12 @@ static pthread_mutex_t g_mutex;
static pthread_cond_t g_cv;

static void
signal_event_loop(void)
#if !defined(__clang__) && defined(__GNUC__)
/* gcc with thread sanitizer enabled reports a double lock when
pthread_cond_signal is called under a locked mutex */
__attribute__((no_sanitize("thread")))
#endif /* !__clang__ && __GNUC__ */
signal_event_loop(void)
{
pthread_mutex_lock(&g_mutex);
pthread_cond_signal(&g_cv);
Expand Down
2 changes: 1 addition & 1 deletion docker/apps/Dockerfile.cloud-server-debug
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY ./ /iotivity-lite/
RUN cd /iotivity-lite/ && git submodule update --recursive
RUN mkdir /iotivity-lite/build && \
cd /iotivity-lite/build && \
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTING=OFF -DOC_CLOUD_ENABLED=ON ${BUILD_ARGS} .. && \
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_TESTING=OFF -DOC_CLOUD_ENABLED=ON ${BUILD_ARGS} .. && \
cmake --build . --target cloud_server
RUN cp /iotivity-lite/build/apps/cloud_server /iotivity-lite/port/linux/service

Expand Down
6 changes: 6 additions & 0 deletions util/oc_compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
#define OC_RETURNS_NONNULL
#endif

#if defined(__clang__) || defined(__GNUC__)
#define OC_NO_SANITIZE(...) __attribute__((no_sanitize(__VA_ARGS__)))
#else
#define OC_NO_SANITIZE(...)
#endif

#if defined(__clang__) || defined(__GNUC__)
#if defined(__MINGW32__) && defined(__USE_MINGW_ANSI_STDIO) && \
__USE_MINGW_ANSI_STDIO == 1
Expand Down

0 comments on commit ee03010

Please sign in to comment.