[multiple] use thread-safe strerror where avail
use ck_strerror_s() to use strerror_s() or strerror_r() thread-safe and constraint-checking interfaces, where available.personal/stbuehler/tests-path
parent
86c39754f2
commit
0286bdef0c
|
@ -883,6 +883,7 @@ add_executable(test_configfile
|
|||
vector.c
|
||||
log.c
|
||||
sock_addr.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_configfile COMMAND test_configfile)
|
||||
|
||||
|
@ -893,6 +894,7 @@ add_executable(test_keyvalue
|
|||
base64.c
|
||||
array.c
|
||||
log.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_keyvalue COMMAND test_keyvalue)
|
||||
|
||||
|
@ -901,6 +903,7 @@ add_executable(test_mod_access
|
|||
buffer.c
|
||||
array.c
|
||||
log.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_mod_access COMMAND test_mod_access)
|
||||
|
||||
|
@ -909,6 +912,7 @@ add_executable(test_mod_evhost
|
|||
buffer.c
|
||||
array.c
|
||||
log.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_mod_evhost COMMAND test_mod_evhost)
|
||||
|
||||
|
@ -917,6 +921,7 @@ add_executable(test_mod_simple_vhost
|
|||
buffer.c
|
||||
array.c
|
||||
log.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_mod_simple_vhost COMMAND test_mod_simple_vhost)
|
||||
|
||||
|
@ -925,6 +930,7 @@ add_executable(test_mod_userdir
|
|||
buffer.c
|
||||
array.c
|
||||
log.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_mod_userdir COMMAND test_mod_userdir)
|
||||
|
||||
|
@ -938,6 +944,7 @@ add_executable(test_request
|
|||
http_kv.c
|
||||
log.c
|
||||
sock_addr.c
|
||||
ck.c
|
||||
)
|
||||
add_test(NAME test_request COMMAND test_request)
|
||||
|
||||
|
|
|
@ -636,25 +636,25 @@ t_test_base64_LDADD = $(LIBUNWIND_LIBS)
|
|||
t_test_burl_SOURCES = t/test_burl.c burl.c buffer.c base64.c
|
||||
t_test_burl_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_configfile_SOURCES = t/test_configfile.c buffer.c array.c data_config.c http_header.c http_kv.c vector.c log.c sock_addr.c
|
||||
t_test_configfile_SOURCES = t/test_configfile.c buffer.c array.c data_config.c http_header.c http_kv.c vector.c log.c sock_addr.c ck.c
|
||||
t_test_configfile_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_keyvalue_SOURCES = t/test_keyvalue.c burl.c buffer.c base64.c array.c log.c
|
||||
t_test_keyvalue_SOURCES = t/test_keyvalue.c burl.c buffer.c base64.c array.c log.c ck.c
|
||||
t_test_keyvalue_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_mod_access_SOURCES = t/test_mod_access.c buffer.c array.c log.c
|
||||
t_test_mod_access_SOURCES = t/test_mod_access.c buffer.c array.c log.c ck.c
|
||||
t_test_mod_access_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c buffer.c array.c log.c
|
||||
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c buffer.c array.c log.c ck.c
|
||||
t_test_mod_evhost_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c buffer.c array.c log.c
|
||||
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c buffer.c array.c log.c ck.c
|
||||
t_test_mod_simple_vhost_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_mod_userdir_SOURCES = t/test_mod_userdir.c buffer.c array.c log.c
|
||||
t_test_mod_userdir_SOURCES = t/test_mod_userdir.c buffer.c array.c log.c ck.c
|
||||
t_test_mod_userdir_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
t_test_request_SOURCES = t/test_request.c base64.c buffer.c burl.c array.c http_header.c http_kv.c log.c sock_addr.c
|
||||
t_test_request_SOURCES = t/test_request.c base64.c buffer.c burl.c array.c http_header.c http_kv.c log.c sock_addr.c ck.c
|
||||
t_test_request_LDADD = $(LIBUNWIND_LIBS)
|
||||
|
||||
noinst_HEADERS = $(hdr)
|
||||
|
|
|
@ -248,9 +248,8 @@ __attribute_cold__
|
|||
static void gw_proc_connect_error(request_st * const r, gw_host *host, gw_proc *proc, pid_t pid, int errnum, int debug) {
|
||||
const time_t cur_ts = log_monotonic_secs;
|
||||
log_error_st * const errh = r->conf.errh;
|
||||
log_error(errh, __FILE__, __LINE__,
|
||||
"establishing connection failed: socket: %s: %s",
|
||||
proc->connection_name->ptr, strerror(errnum));
|
||||
log_perror(errh, __FILE__, __LINE__, /*(caller should set errno = errnum)*/
|
||||
"establishing connection failed: socket: %s", proc->connection_name->ptr);
|
||||
|
||||
if (!proc->is_local) {
|
||||
proc->disabled_until = cur_ts + host->disable_time;
|
||||
|
@ -1919,6 +1918,7 @@ static handler_t gw_write_request(gw_handler_ctx * const hctx, request_st * cons
|
|||
if (hctx->state == GW_STATE_CONNECT_DELAYED) { /*(not GW_STATE_INIT)*/
|
||||
int socket_error = fdevent_connect_status(hctx->fd);
|
||||
if (socket_error != 0) {
|
||||
errno = socket_error; /*(for log_perror())*/
|
||||
gw_proc_connect_error(r, hctx->host, hctx->proc, hctx->pid,
|
||||
socket_error, hctx->conf.debug);
|
||||
return HANDLER_ERROR;
|
||||
|
|
17
src/log.c
17
src/log.c
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "first.h"
|
||||
|
||||
#include "ck.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -166,6 +167,16 @@ log_buffer_vprintf (buffer * const b,
|
|||
}
|
||||
|
||||
|
||||
__attribute_noinline__
|
||||
static void
|
||||
log_error_append_strerror (buffer * const b, const int errnum)
|
||||
{
|
||||
char buf[1024];
|
||||
errno_t rc = ck_strerror_s(buf, sizeof(buf), errnum);
|
||||
if (0 == rc || rc == ERANGE)
|
||||
buffer_append_str2(b, CONST_STR_LEN(": "), buf, strlen(buf));
|
||||
}
|
||||
|
||||
__attribute_format__((__printf__, 4, 0))
|
||||
static void
|
||||
log_error_va_list_impl (log_error_st * const errh,
|
||||
|
@ -178,10 +189,8 @@ log_error_va_list_impl (log_error_st * const errh,
|
|||
buffer * const b = &errh->b;
|
||||
if (-1 == log_buffer_prepare(errh, filename, line, b)) return;
|
||||
log_buffer_vprintf(b, fmt, ap);
|
||||
if (perr) {
|
||||
buffer_append_string_len(b, CONST_STR_LEN(": "));
|
||||
buffer_append_string(b, strerror(errnum));
|
||||
}
|
||||
if (perr)
|
||||
log_error_append_strerror(b, errnum);
|
||||
log_write(errh, b);
|
||||
errno = errnum;
|
||||
}
|
||||
|
|
|
@ -896,6 +896,7 @@ test('test_configfile', executable('test_configfile',
|
|||
'vector.c',
|
||||
'log.c',
|
||||
'sock_addr.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libpcre + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -909,6 +910,7 @@ test('test_keyvalue', executable('test_keyvalue',
|
|||
'base64.c',
|
||||
'array.c',
|
||||
'log.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libpcre + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -920,6 +922,7 @@ test('test_mod_access', executable('test_mod_access',
|
|||
'buffer.c',
|
||||
'array.c',
|
||||
'log.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -931,6 +934,7 @@ test('test_mod_evhost', executable('test_mod_evhost',
|
|||
'buffer.c',
|
||||
'array.c',
|
||||
'log.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -942,6 +946,7 @@ test('test_mod_simple_vhost', executable('test_mod_simple_vhost',
|
|||
'buffer.c',
|
||||
'array.c',
|
||||
'log.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -953,6 +958,7 @@ test('test_mod_userdir', executable('test_mod_userdir',
|
|||
'buffer.c',
|
||||
'array.c',
|
||||
'log.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libunwind,
|
||||
build_by_default: false,
|
||||
|
@ -969,6 +975,7 @@ test('test_request', executable('test_request',
|
|||
'http_kv.c',
|
||||
'log.c',
|
||||
'sock_addr.c',
|
||||
'ck.c',
|
||||
],
|
||||
dependencies: common_flags + libunwind,
|
||||
build_by_default: false,
|
||||
|
|
|
@ -3182,8 +3182,9 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
|
|||
if (0==oerrno && 0==cq->bytes_in && !hctx->conf.ssl_log_noise)
|
||||
break;
|
||||
|
||||
log_error(hctx->errh, __FILE__, __LINE__,
|
||||
"SSL: %d %d %d %s", len, rc, oerrno, strerror(oerrno));
|
||||
errno = oerrno; /*(for log_perror())*/
|
||||
log_perror(hctx->errh, __FILE__, __LINE__,
|
||||
"SSL: %d %d %d", len, rc, oerrno);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -2944,8 +2944,9 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
|
|||
if (0==oerrno && 0==cq->bytes_in && !hctx->conf.ssl_log_noise)
|
||||
break;
|
||||
|
||||
log_error(hctx->errh, __FILE__, __LINE__,
|
||||
"SSL: %d %d %d %s", len, rc, oerrno, strerror(oerrno));
|
||||
errno = oerrno; /*(for log_perror())*/
|
||||
log_perror(hctx->errh, __FILE__, __LINE__,
|
||||
"SSL: %d %d %d", len, rc, oerrno);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue