Made nxt_assert() statements to be compiled only with debug.
This commit is contained in:
@@ -122,6 +122,15 @@ nxt_log_debug(_log, ...) \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#define nxt_assert(c) \
|
||||||
|
do { \
|
||||||
|
if (nxt_slow_path(!(c))) { \
|
||||||
|
nxt_thread_log_alert("%s:%d assertion failed: %s", \
|
||||||
|
__FILE__, __LINE__, #c); \
|
||||||
|
nxt_abort(); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define nxt_debug(...)
|
#define nxt_debug(...)
|
||||||
@@ -129,6 +138,8 @@ nxt_log_debug(_log, ...) \
|
|||||||
#define \
|
#define \
|
||||||
nxt_log_debug(...)
|
nxt_log_debug(...)
|
||||||
|
|
||||||
|
#define nxt_assert(c)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -170,17 +181,4 @@ NXT_EXPORT extern nxt_log_t nxt_main_log;
|
|||||||
NXT_EXPORT extern nxt_str_t nxt_log_levels[];
|
NXT_EXPORT extern nxt_str_t nxt_log_levels[];
|
||||||
|
|
||||||
|
|
||||||
#define nxt_assert(c) \
|
|
||||||
do { \
|
|
||||||
if (nxt_fast_path(c)) { \
|
|
||||||
break; \
|
|
||||||
\
|
|
||||||
} else { \
|
|
||||||
nxt_thread_log_alert("%s:%d assertion failed: %s", \
|
|
||||||
__FILE__, __LINE__, #c ); \
|
|
||||||
nxt_abort(); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NXT_LOG_H_INCLUDED_ */
|
#endif /* _NXT_LOG_H_INCLUDED_ */
|
||||||
|
|||||||
@@ -527,14 +527,20 @@ nxt_port_mmap_tracking_cancel(nxt_task_t *task,
|
|||||||
nxt_int_t
|
nxt_int_t
|
||||||
nxt_port_mmap_tracking_write(uint32_t *buf, nxt_port_mmap_tracking_t *t)
|
nxt_port_mmap_tracking_write(uint32_t *buf, nxt_port_mmap_tracking_t *t)
|
||||||
{
|
{
|
||||||
nxt_atomic_t *tracking;
|
|
||||||
nxt_port_mmap_handler_t *mmap_handler;
|
nxt_port_mmap_handler_t *mmap_handler;
|
||||||
|
|
||||||
mmap_handler = t->mmap_handler;
|
mmap_handler = t->mmap_handler;
|
||||||
|
|
||||||
|
#if (NXT_DEBUG)
|
||||||
|
{
|
||||||
|
nxt_atomic_t *tracking;
|
||||||
|
|
||||||
tracking = mmap_handler->hdr->tracking;
|
tracking = mmap_handler->hdr->tracking;
|
||||||
|
|
||||||
nxt_assert(t->tracking >= tracking);
|
nxt_assert(t->tracking >= tracking);
|
||||||
nxt_assert(t->tracking < tracking + PORT_MMAP_CHUNK_COUNT);
|
nxt_assert(t->tracking < tracking + PORT_MMAP_CHUNK_COUNT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
buf[0] = mmap_handler->hdr->id;
|
buf[0] = mmap_handler->hdr->id;
|
||||||
buf[1] = t->tracking - mmap_handler->hdr->tracking;
|
buf[1] = t->tracking - mmap_handler->hdr->tracking;
|
||||||
|
|||||||
@@ -117,11 +117,15 @@ nxt_router_ra_inc_use(nxt_req_app_link_t *ra)
|
|||||||
nxt_inline void
|
nxt_inline void
|
||||||
nxt_router_ra_dec_use(nxt_req_app_link_t *ra)
|
nxt_router_ra_dec_use(nxt_req_app_link_t *ra)
|
||||||
{
|
{
|
||||||
|
#if (NXT_DEBUG)
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
c = nxt_atomic_fetch_add(&ra->use_count, -1);
|
c = nxt_atomic_fetch_add(&ra->use_count, -1);
|
||||||
|
|
||||||
nxt_assert(c > 1);
|
nxt_assert(c > 1);
|
||||||
|
#else
|
||||||
|
(void) nxt_atomic_fetch_add(&ra->use_count, -1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nxt_router_ra_use(nxt_task_t *task, nxt_req_app_link_t *ra, int i);
|
static void nxt_router_ra_use(nxt_task_t *task, nxt_req_app_link_t *ra, int i);
|
||||||
@@ -3005,18 +3009,24 @@ nxt_router_app_quit(nxt_task_t *task, nxt_app_t *app)
|
|||||||
static void
|
static void
|
||||||
nxt_router_app_process_request(nxt_task_t *task, void *obj, void *data)
|
nxt_router_app_process_request(nxt_task_t *task, void *obj, void *data)
|
||||||
{
|
{
|
||||||
nxt_app_t *app;
|
|
||||||
nxt_req_app_link_t *ra;
|
nxt_req_app_link_t *ra;
|
||||||
|
|
||||||
app = obj;
|
|
||||||
ra = data;
|
ra = data;
|
||||||
|
|
||||||
|
#if (NXT_DEBUG)
|
||||||
|
{
|
||||||
|
nxt_app_t *app;
|
||||||
|
|
||||||
|
app = obj;
|
||||||
|
|
||||||
nxt_assert(app != NULL);
|
nxt_assert(app != NULL);
|
||||||
nxt_assert(ra != NULL);
|
nxt_assert(ra != NULL);
|
||||||
nxt_assert(ra->app_port != NULL);
|
nxt_assert(ra->app_port != NULL);
|
||||||
|
|
||||||
nxt_debug(task, "app '%V' %p process next stream #%uD",
|
nxt_debug(task, "app '%V' %p process next stream #%uD",
|
||||||
&app->name, app, ra->stream);
|
&app->name, app, ra->stream);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nxt_router_app_prepare_request(task, ra);
|
nxt_router_app_prepare_request(task, ra);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user