Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions plugins/multiplexer/dispatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ copy(const TSIOBufferReader &r, const TSIOBuffer b)
const void *const pointer = TSIOBufferBlockReadStart(block, r, &size);

if (pointer != nullptr && size > 0) {
const int64_t size2 = TSIOBufferWrite(b, pointer, size);
assert(size == size2);
CHECK(TSIOBufferWrite(b, pointer, size) == size);
length += size;
}
}
Expand Down
28 changes: 24 additions & 4 deletions plugins/multiplexer/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,32 @@

#include "ts.h"

#define CHECK(X) \
{ \
const TSReturnCode r = static_cast<TSReturnCode>(X); \
assert(r == TS_SUCCESS); \
#ifdef __OPTIMIZE__
Comment thread
bneradt marked this conversation as resolved.

// Optimized -- release build.

// For CHECK(), execute any side effects (only) for expression X.
#define CHECK(X) \
{ \
static_cast<void>(X); \
}

// Make sure assert() disabled.
#ifndef NDEBUG
#define NDEBUG
#endif

#else

// Check if expression X returns a value that implicitly converts to bool false (such as TS_SUCCESS).
#define CHECK(X) \
{ \
static_assert(!TS_SUCCESS); \
assert(!(X)); \
}

#endif

struct Statistics {
int failures;
int hits;
Expand Down
3 changes: 1 addition & 2 deletions plugins/multiplexer/original-request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ OriginalRequest::urlScheme(const std::string &s)
{
assert(buffer_ != nullptr);
assert(url_ != nullptr);
const TSReturnCode result = TSUrlSchemeSet(buffer_, url_, s.c_str(), s.size());
assert(result == TS_SUCCESS);
CHECK(TSUrlSchemeSet(buffer_, url_, s.c_str(), s.size()));
}

void
Expand Down