diff options
Diffstat (limited to '')
-rw-r--r-- | src/nxt_log.h | 24 | ||||
-rw-r--r-- | src/nxt_port_memory.c | 8 | ||||
-rw-r--r-- | src/nxt_router.c | 14 |
3 files changed, 30 insertions, 16 deletions
diff --git a/src/nxt_log.h b/src/nxt_log.h index e32feb14..f5e60129 100644 --- a/src/nxt_log.h +++ b/src/nxt_log.h @@ -122,6 +122,15 @@ nxt_log_debug(_log, ...) \ } 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 #define nxt_debug(...) @@ -129,6 +138,8 @@ nxt_log_debug(_log, ...) \ #define \ nxt_log_debug(...) +#define nxt_assert(c) + #endif @@ -170,17 +181,4 @@ NXT_EXPORT extern nxt_log_t nxt_main_log; 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_ */ diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c index a44cee01..31bab352 100644 --- a/src/nxt_port_memory.c +++ b/src/nxt_port_memory.c @@ -527,14 +527,20 @@ nxt_port_mmap_tracking_cancel(nxt_task_t *task, nxt_int_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; mmap_handler = t->mmap_handler; + +#if (NXT_DEBUG) + { + nxt_atomic_t *tracking; + tracking = mmap_handler->hdr->tracking; nxt_assert(t->tracking >= tracking); nxt_assert(t->tracking < tracking + PORT_MMAP_CHUNK_COUNT); + } +#endif buf[0] = mmap_handler->hdr->id; buf[1] = t->tracking - mmap_handler->hdr->tracking; diff --git a/src/nxt_router.c b/src/nxt_router.c index 53761e4f..36f5264d 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -117,11 +117,15 @@ nxt_router_ra_inc_use(nxt_req_app_link_t *ra) nxt_inline void nxt_router_ra_dec_use(nxt_req_app_link_t *ra) { +#if (NXT_DEBUG) int c; c = nxt_atomic_fetch_add(&ra->use_count, -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); @@ -3005,18 +3009,24 @@ nxt_router_app_quit(nxt_task_t *task, nxt_app_t *app) static void nxt_router_app_process_request(nxt_task_t *task, void *obj, void *data) { - nxt_app_t *app; nxt_req_app_link_t *ra; - app = obj; ra = data; +#if (NXT_DEBUG) + { + nxt_app_t *app; + + app = obj; + nxt_assert(app != NULL); nxt_assert(ra != NULL); nxt_assert(ra->app_port != NULL); nxt_debug(task, "app '%V' %p process next stream #%uD", &app->name, app, ra->stream); + } +#endif nxt_router_app_prepare_request(task, ra); } |