From dbb0df5c5b129dab008f63866fe327bc53a4aed4 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 25 Feb 2013 22:43:44 +0900 Subject: [PATCH] Remove strerror(3) from code which may run in multi-thread --- src/shrpx_listen_handler.cc | 4 ++-- src/shrpx_spdy_session.cc | 6 +++--- src/shrpx_spdy_upstream.cc | 4 ++-- src/shrpx_ssl.cc | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/shrpx_listen_handler.cc b/src/shrpx_listen_handler.cc index 3e876966..6a2dacda 100644 --- a/src/shrpx_listen_handler.cc +++ b/src/shrpx_listen_handler.cc @@ -67,14 +67,14 @@ void ListenHandler::create_worker_thread(size_t num) WorkerInfo *info = &workers_[num_worker_]; rv = socketpair(AF_UNIX, SOCK_STREAM, 0, info->sv); if(rv == -1) { - LLOG(ERROR, this) << "socketpair() failed: " << strerror(errno); + LLOG(ERROR, this) << "socketpair() failed: errno=" << errno; continue; } info->sv_ssl_ctx = sv_ssl_ctx_; info->cl_ssl_ctx = cl_ssl_ctx_; rv = pthread_create(&thread, &attr, start_threaded_worker, info); if(rv != 0) { - LLOG(ERROR, this) << "pthread_create() failed: " << strerror(rv); + LLOG(ERROR, this) << "pthread_create() failed: errno=" << rv; for(size_t j = 0; j < 2; ++j) { close(info->sv[j]); } diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index e702c10a..187db71c 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -186,7 +186,7 @@ int SpdySession::init_notification() int sockpair[2]; rv = socketpair(AF_UNIX, SOCK_STREAM, 0, sockpair); if(rv == -1) { - SSLOG(FATAL, this) << "socketpair() failed: " << strerror(errno); + SSLOG(FATAL, this) << "socketpair() failed: errno=" << errno; return -1; } wrbev_ = bufferevent_socket_new(evbase_, sockpair[0], @@ -258,8 +258,8 @@ void eventcb(bufferevent *bev, short events, void *ptr) int val = 1; if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&val), sizeof(val)) == -1) { - SSLOG(WARNING, spdy) << "Setting option TCP_NODELAY failed: " - << strerror(errno); + SSLOG(WARNING, spdy) << "Setting option TCP_NODELAY failed: errno=" + << errno; } } else if(events & BEV_EVENT_EOF) { if(LOG_ENABLED(INFO)) { diff --git a/src/shrpx_spdy_upstream.cc b/src/shrpx_spdy_upstream.cc index 51a482e9..89e2f341 100644 --- a/src/shrpx_spdy_upstream.cc +++ b/src/shrpx_spdy_upstream.cc @@ -518,8 +518,8 @@ void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr) int val = 1; if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&val), sizeof(val)) == -1) { - DCLOG(WARNING, dconn) << "Setting option TCP_NODELAY failed: " - << strerror(errno); + DCLOG(WARNING, dconn) << "Setting option TCP_NODELAY failed: errno=" + << errno; } } else if(events & BEV_EVENT_EOF) { if(LOG_ENABLED(INFO)) { diff --git a/src/shrpx_ssl.cc b/src/shrpx_ssl.cc index 08332dab..57ccdb6d 100644 --- a/src/shrpx_ssl.cc +++ b/src/shrpx_ssl.cc @@ -261,8 +261,8 @@ ClientHandler* accept_connection(event_base *evbase, SSL_CTX *ssl_ctx, rv = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&val), sizeof(val)); if(rv == -1) { - LOG(WARNING) << "Setting option TCP_NODELAY failed: " - << strerror(errno); + LOG(WARNING) << "Setting option TCP_NODELAY failed: errno=" + << errno; } SSL *ssl = 0; bufferevent *bev;