diff --git a/include/proxysql.h b/include/proxysql.h index 90c881d414..8b6d1d4d50 100644 --- a/include/proxysql.h +++ b/include/proxysql.h @@ -117,6 +117,10 @@ void proxy_info_(const char* msg, ...); #ifdef DEBUG void init_debug_struct(); void init_debug_struct_from_cmdline(); +/** + * @brief Add a debug entry in the error log. To be used through 'proxy_debug' macro. + * @details This function saves/restores the previous 'errno' value. + */ __attribute__((__format__ (__printf__, 7, 8))) void proxy_debug_func(enum debug_module, int, int, const char *, int, const char *, const char *, ...); void proxy_debug_get_filters(std::set&); diff --git a/lib/debug.cpp b/lib/debug.cpp index e4eda648f5..4f3755c9c0 100644 --- a/lib/debug.cpp +++ b/lib/debug.cpp @@ -131,15 +131,22 @@ void proxy_debug_load_filters(std::set& f) { //pthread_mutex_unlock(&debug_mutex); } +// REMINDER: This function should always save/restore 'errno', otherwise it could influence error handling. void proxy_debug_func(enum debug_module module, int verbosity, int thr, const char *__file, int __line, const char *__func, const char *fmt, ...) { + int saved_errno = errno; assert(module