Suppress assert()'s in the production builds.

Change-Id: I2074ed335b7201337e6519440ff6bed1809be915
private/mmeeks/fixing
Jan Holesovsky 2017-04-05 11:57:28 +02:00
parent d345c29a47
commit 37387518f4
4 changed files with 25 additions and 3 deletions

View File

@ -27,6 +27,10 @@ AM_CPPFLAGS = -pthread -DLOOLWSD_DATADIR='"@LOOLWSD_DATADIR@"' \
-DDEBUG_ABSSRCDIR='"@abs_srcdir@"' \
${include_paths}
if !ENABLE_DEBUG
AM_CPPFLAGS += -DNDEBUG
endif
AM_LDFLAGS = -pthread -Wl,-E,-rpath,/snap/loolwsd/current/usr/lib $(ZLIB_LIBS)
if ENABLE_SSL

View File

@ -77,12 +77,20 @@ namespace Util
template <typename T>
void assertIsLocked(const T& lock)
{
#ifdef NDEBUG
(void) lock;
#else
assert(lock.owns_lock());
#endif
}
inline void assertIsLocked(std::mutex& mtx)
{
#ifdef NDEBUG
(void) mtx;
#else
assert(!mtx.try_lock());
#endif
}
/// Returns the process PSS in KB (works only when we have perms for /proc/pid/smaps).

View File

@ -246,6 +246,7 @@ AS_IF([test "$enable_ssl" != "no"],
[AC_DEFINE([ENABLE_SSL],0,[Whether to enable SSL])])
AM_CONDITIONAL([ENABLE_SSL], [test "$enable_ssl" != "no"])
AM_CONDITIONAL([ENABLE_DEBUG], [test "$ENABLE_DEBUG" = "true"])
ENABLE_SSL=
if test "$enable_ssl" != "no"; then

View File

@ -144,7 +144,10 @@ struct ThreadWorker : public Runnable
{
Session ping(_domain ? _domain : "init", EnableHttps);
ping.sendPing(i);
int back = ping.getResponseInt();
#ifndef NDEBUG
int back =
#endif
ping.getResponseInt();
assert(back == i + 1);
}
}
@ -209,7 +212,10 @@ struct Client : public Poco::Util::Application
ws->sendFrame(&i, sizeof(i), WebSocket::SendFlags::FRAME_BINARY);
size_t back[5];
int flags = 0;
int recvd = ws->receiveFrame((void *)back, sizeof(back), flags);
#ifndef NDEBUG
int recvd =
#endif
ws->receiveFrame((void *)back, sizeof(back), flags);
assert(recvd == sizeof(size_t));
assert(back[0] == i + 1);
}
@ -233,7 +239,10 @@ struct Client : public Poco::Util::Application
res.resize(i);
int flags;
int recvd = ws->receiveFrame(res.data(), res.size(), flags);
#ifndef NDEBUG
int recvd =
#endif
ws->receiveFrame(res.data(), res.size(), flags);
assert(recvd == static_cast<int>(i));
if (i == sizeof(size_t))