Merge pull request #25212 from grpc/revert-25140-strerror

Revert "Wrap strerror into a thread-safe implementation"
pull/25228/head
Yang Gao 4 years ago committed by GitHub
commit 9996cacb8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      BUILD
  2. 2
      BUILD.gn
  3. 1
      CMakeLists.txt
  4. 1
      Makefile
  5. 2
      build_autogenerated.yaml
  6. 1
      config.m4
  7. 1
      config.w32
  8. 2
      gRPC-C++.podspec
  9. 3
      gRPC-Core.podspec
  10. 2
      grpc.gemspec
  11. 1
      grpc.gyp
  12. 2
      package.xml
  13. 8
      src/core/lib/gpr/cpu_linux.cc
  14. 103
      src/core/lib/gpr/strerror.cc
  15. 35
      src/core/lib/gpr/strerror.h
  16. 5
      src/core/lib/gpr/tmpfile_posix.cc
  17. 5
      src/core/lib/gprpp/stat_posix.cc
  18. 5
      src/core/lib/gprpp/stat_windows.cc
  19. 9
      src/core/lib/iomgr/error.cc
  20. 7
      src/core/lib/iomgr/ev_epoll1_linux.cc
  21. 3
      src/core/lib/iomgr/internal_errqueue.cc
  22. 5
      src/core/lib/iomgr/socket_utils_common_posix.cc
  23. 10
      src/core/lib/iomgr/tcp_server_posix.cc
  24. 15
      src/core/lib/iomgr/udp_server.cc
  25. 4
      src/core/lib/iomgr/wakeup_fd_pipe.cc
  26. 1
      src/python/grpcio/grpc_core_dependencies.py
  27. 6
      test/core/iomgr/fd_posix_test.cc
  28. 3
      test/core/iomgr/tcp_server_posix_test.cc
  29. 41
      test/core/network_benchmarks/low_level_ping_pong.cc
  30. 4
      test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc
  31. 6
      test/core/util/subprocess_posix.cc
  32. 2
      tools/doxygen/Doxyfile.c++.internal
  33. 2
      tools/doxygen/Doxyfile.core.internal

@ -540,7 +540,6 @@ grpc_cc_library(
"src/core/lib/gpr/log_posix.cc",
"src/core/lib/gpr/log_windows.cc",
"src/core/lib/gpr/murmur_hash.cc",
"src/core/lib/gpr/strerror.cc",
"src/core/lib/gpr/string.cc",
"src/core/lib/gpr/string_posix.cc",
"src/core/lib/gpr/string_util_windows.cc",
@ -577,7 +576,6 @@ grpc_cc_library(
"src/core/lib/gpr/env.h",
"src/core/lib/gpr/murmur_hash.h",
"src/core/lib/gpr/spinlock.h",
"src/core/lib/gpr/strerror.h",
"src/core/lib/gpr/string.h",
"src/core/lib/gpr/string_windows.h",
"src/core/lib/gpr/time_precise.h",

@ -117,8 +117,6 @@ config("grpc_config") {
"src/core/lib/gpr/murmur_hash.cc",
"src/core/lib/gpr/murmur_hash.h",
"src/core/lib/gpr/spinlock.h",
"src/core/lib/gpr/strerror.cc",
"src/core/lib/gpr/strerror.h",
"src/core/lib/gpr/string.cc",
"src/core/lib/gpr/string.h",
"src/core/lib/gpr/string_posix.cc",

@ -1308,7 +1308,6 @@ add_library(gpr
src/core/lib/gpr/log_posix.cc
src/core/lib/gpr/log_windows.cc
src/core/lib/gpr/murmur_hash.cc
src/core/lib/gpr/strerror.cc
src/core/lib/gpr/string.cc
src/core/lib/gpr/string_posix.cc
src/core/lib/gpr/string_util_windows.cc

@ -920,7 +920,6 @@ LIBGPR_SRC = \
src/core/lib/gpr/log_posix.cc \
src/core/lib/gpr/log_windows.cc \
src/core/lib/gpr/murmur_hash.cc \
src/core/lib/gpr/strerror.cc \
src/core/lib/gpr/string.cc \
src/core/lib/gpr/string_posix.cc \
src/core/lib/gpr/string_util_windows.cc \

@ -283,7 +283,6 @@ libs:
- src/core/lib/gpr/env.h
- src/core/lib/gpr/murmur_hash.h
- src/core/lib/gpr/spinlock.h
- src/core/lib/gpr/strerror.h
- src/core/lib/gpr/string.h
- src/core/lib/gpr/string_windows.h
- src/core/lib/gpr/time_precise.h
@ -326,7 +325,6 @@ libs:
- src/core/lib/gpr/log_posix.cc
- src/core/lib/gpr/log_windows.cc
- src/core/lib/gpr/murmur_hash.cc
- src/core/lib/gpr/strerror.cc
- src/core/lib/gpr/string.cc
- src/core/lib/gpr/string_posix.cc
- src/core/lib/gpr/string_util_windows.cc

@ -354,7 +354,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gpr/log_posix.cc \
src/core/lib/gpr/log_windows.cc \
src/core/lib/gpr/murmur_hash.cc \
src/core/lib/gpr/strerror.cc \
src/core/lib/gpr/string.cc \
src/core/lib/gpr/string_posix.cc \
src/core/lib/gpr/string_util_windows.cc \

@ -321,7 +321,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gpr\\log_posix.cc " +
"src\\core\\lib\\gpr\\log_windows.cc " +
"src\\core\\lib\\gpr\\murmur_hash.cc " +
"src\\core\\lib\\gpr\\strerror.cc " +
"src\\core\\lib\\gpr\\string.cc " +
"src\\core\\lib\\gpr\\string_posix.cc " +
"src\\core\\lib\\gpr\\string_util_windows.cc " +

@ -486,7 +486,6 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/murmur_hash.h',
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/strerror.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/time_precise.h',
@ -1105,7 +1104,6 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/murmur_hash.h',
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/strerror.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/time_precise.h',

@ -790,8 +790,6 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/murmur_hash.cc',
'src/core/lib/gpr/murmur_hash.h',
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/strerror.cc',
'src/core/lib/gpr/strerror.h',
'src/core/lib/gpr/string.cc',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_posix.cc',
@ -1638,7 +1636,6 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/murmur_hash.h',
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/strerror.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/time_precise.h',

@ -705,8 +705,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gpr/murmur_hash.cc )
s.files += %w( src/core/lib/gpr/murmur_hash.h )
s.files += %w( src/core/lib/gpr/spinlock.h )
s.files += %w( src/core/lib/gpr/strerror.cc )
s.files += %w( src/core/lib/gpr/strerror.h )
s.files += %w( src/core/lib/gpr/string.cc )
s.files += %w( src/core/lib/gpr/string.h )
s.files += %w( src/core/lib/gpr/string_posix.cc )

@ -404,7 +404,6 @@
'src/core/lib/gpr/log_posix.cc',
'src/core/lib/gpr/log_windows.cc',
'src/core/lib/gpr/murmur_hash.cc',
'src/core/lib/gpr/strerror.cc',
'src/core/lib/gpr/string.cc',
'src/core/lib/gpr/string_posix.cc',
'src/core/lib/gpr/string_util_windows.cc',

@ -685,8 +685,6 @@
<file baseinstalldir="/" name="src/core/lib/gpr/murmur_hash.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/murmur_hash.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/spinlock.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/strerror.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/strerror.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/string.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/string.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/string_posix.cc" role="src" />

@ -33,15 +33,12 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/gpr/strerror.h"
static int ncpus = 0;
static void init_num_cpus() {
#ifndef GPR_MUSL_LIBC_COMPAT
if (sched_getcpu() < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
ncpus = 1;
return;
}
@ -71,8 +68,7 @@ unsigned gpr_cpu_current_cpu(void) {
}
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
return 0;
}
if (static_cast<unsigned>(cpu) >= gpr_cpu_num_cores()) {

@ -1,103 +0,0 @@
/*
*
* Copyright 2020 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/gpr/strerror.h"
#include <array>
#include <cerrno>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <string>
#include <type_traits>
// The implementation below is mostly copied from abseil because it is internal
// there.
namespace grpc_core {
namespace {
// `ErrnoSaver` captures the value of `errno` upon construction and restores it
// upon deletion. It is used in low-level code and must be super fast. Do not
// add instrumentation, even in debug modes.
class ErrnoSaver {
public:
ErrnoSaver() : saved_errno_(errno) {}
~ErrnoSaver() { errno = saved_errno_; }
int operator()() const { return saved_errno_; }
private:
const int saved_errno_;
};
const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) {
#if defined(GPR_WINDOWS)
int rc = strerror_s(buf, buflen, errnum);
buf[buflen - 1] = '\0'; // guarantee NUL termination
if (rc == 0 && strncmp(buf, "Unknown error", buflen) == 0) *buf = '\0';
return buf;
#else
// The type of `ret` is platform-specific; both of these branches must compile
// either way but only one will execute on any given platform:
auto ret = strerror_r(errnum, buf, buflen);
if (std::is_same<decltype(ret), int>::value) {
// XSI `strerror_r`; `ret` is `int`:
if (ret) *buf = '\0';
return buf;
} else {
// GNU `strerror_r`; `ret` is `char *`:
return reinterpret_cast<const char*>(ret);
}
#endif
}
std::string StrErrorInternal(int errnum) {
char buf[100];
const char* str = StrErrorAdaptor(errnum, buf, sizeof buf);
if (*str == '\0') {
snprintf(buf, sizeof buf, "Unknown error %d", errnum);
str = buf;
}
return str;
}
// kSysNerr is the number of errors from a recent glibc. `StrError()` falls back
// to `StrErrorAdaptor()` if the value is larger than this.
constexpr int kSysNerr = 135;
std::array<std::string, kSysNerr>* NewStrErrorTable() {
auto* table = new std::array<std::string, kSysNerr>;
for (int i = 0; i < static_cast<int>(table->size()); ++i) {
(*table)[i] = StrErrorInternal(i);
}
return table;
}
} // namespace
std::string StrError(int errnum) {
ErrnoSaver errno_saver;
static const auto* table = NewStrErrorTable();
if (errnum >= 0 && errnum < static_cast<int>(table->size())) {
return (*table)[errnum];
}
return StrErrorInternal(errnum);
}
} // namespace grpc_core

@ -1,35 +0,0 @@
/*
*
* Copyright 2020 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPC_CORE_LIB_GPR_STRERROR_H
#define GRPC_CORE_LIB_GPR_STRERROR_H
#include <grpc/support/port_platform.h>
#include <string>
namespace grpc_core {
// `strerror` is not thread-safe. This wrapper is a portable thread-safe
// implementation. It does not modify `errno`.
// The implementation is copied from abseil's internal.
std::string StrError(int errnum);
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPR_STRERROR_H */

@ -31,7 +31,6 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/string.h"
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
@ -47,13 +46,13 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename) {
fd = mkstemp(filename_template);
if (fd == -1) {
gpr_log(GPR_ERROR, "mkstemp failed for filename_template %s with error %s.",
filename_template, grpc_core::StrError(errno).c_str());
filename_template, strerror(errno));
goto end;
}
result = fdopen(fd, "w+");
if (result == nullptr) {
gpr_log(GPR_ERROR, "Could not open file %s from fd %d (error = %s).",
filename_template, fd, grpc_core::StrError(errno).c_str());
filename_template, fd, strerror(errno));
unlink(filename_template);
close(fd);
goto end;

@ -25,7 +25,6 @@
#include <grpc/support/log.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gprpp/stat.h"
namespace grpc_core {
@ -35,9 +34,9 @@ absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
GPR_ASSERT(timestamp != nullptr);
struct stat buf;
if (stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno);
const char* error_msg = strerror(errno);
gpr_log(GPR_ERROR, "stat failed for filename %s with error %s.", filename,
error_msg.c_str());
error_msg);
return absl::Status(absl::StatusCode::kInternal, error_msg);
}
// Last file/directory modification time.

@ -24,7 +24,6 @@
#include <grpc/support/log.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gprpp/stat.h"
namespace grpc_core {
@ -34,9 +33,9 @@ absl::Status GetFileModificationTime(const char* filename, time_t* timestamp) {
GPR_ASSERT(timestamp != nullptr);
struct _stat buf;
if (_stat(filename, &buf) != 0) {
std::string error_msg = StrError(errno);
const char* error_msg = strerror(errno);
gpr_log(GPR_ERROR, "_stat failed for filename %s with error %s.", filename,
error_msg.c_str());
error_msg);
return absl::Status(absl::StatusCode::kInternal, error_msg);
}
// Last file/directory modification time.

@ -32,7 +32,6 @@
#endif
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/iomgr/error_internal.h"
#include "src/core/lib/profiling/timers.h"
@ -778,15 +777,15 @@ const char* grpc_error_string(grpc_error* err) {
grpc_error* grpc_os_error(const char* file, int line, int err,
const char* call_name) {
std::string err_string = grpc_core::StrError(err);
return grpc_error_set_str(
grpc_error_set_str(
grpc_error_set_int(
grpc_error_create(file, line,
grpc_slice_from_cpp_string(err_string), nullptr,
0),
grpc_slice_from_static_string(strerror(err)),
nullptr, 0),
GRPC_ERROR_INT_ERRNO, err),
GRPC_ERROR_STR_OS_ERROR, grpc_slice_from_cpp_string(err_string)),
GRPC_ERROR_STR_OS_ERROR,
grpc_slice_from_static_string(strerror(err))),
GRPC_ERROR_STR_SYSCALL, grpc_slice_from_copied_string(call_name));
}

@ -49,7 +49,6 @@
#include <grpc/support/cpu.h>
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/gpr/useful.h"
@ -372,8 +371,7 @@ static grpc_fd* fd_create(int fd, const char* name, bool track_err) {
ev.data.ptr = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(new_fd) |
(track_err ? 1 : 0));
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_ADD, fd, &ev) != 0) {
gpr_log(GPR_ERROR, "epoll_ctl failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno));
}
return new_fd;
@ -394,8 +392,7 @@ static void fd_shutdown_internal(grpc_fd* fd, grpc_error* why,
epoll_event dummy_event;
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_DEL, fd->fd, &dummy_event) !=
0) {
gpr_log(GPR_ERROR, "epoll_ctl failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno));
}
}
fd->write_closure->SetShutdown(GRPC_ERROR_REF(why));

@ -21,7 +21,6 @@
#include "src/core/lib/iomgr/port.h"
#include <grpc/impl/codegen/log.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/iomgr/internal_errqueue.h"
#ifdef GRPC_POSIX_SOCKET_TCP
@ -42,7 +41,7 @@ void grpc_errqueue_init() {
#ifdef GRPC_LINUX_ERRQUEUE
struct utsname buffer;
if (uname(&buffer) != 0) {
gpr_log(GPR_ERROR, "uname: %s", StrError(errno).c_str());
gpr_log(GPR_ERROR, "uname: %s", strerror(errno));
return;
}
char* release = buffer.release;

@ -48,7 +48,6 @@
#include <grpc/support/sync.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
@ -364,12 +363,12 @@ grpc_error* grpc_set_socket_tcp_user_timeout(
if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout,
sizeof(timeout))) {
gpr_log(GPR_ERROR, "setsockopt(TCP_USER_TIMEOUT) %s",
grpc_core::StrError(errno).c_str());
strerror(errno));
return GRPC_ERROR_NONE;
}
if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) {
gpr_log(GPR_ERROR, "getsockopt(TCP_USER_TIMEOUT) %s",
grpc_core::StrError(errno).c_str());
strerror(errno));
return GRPC_ERROR_NONE;
}
if (newval != timeout) {

@ -48,7 +48,6 @@
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/exec_ctx.h"
@ -214,8 +213,7 @@ static void on_read(void* arg, grpc_error* err) {
default:
gpr_mu_lock(&sp->server->mu);
if (!sp->server->shutdown_listeners) {
gpr_log(GPR_ERROR, "Failed accept4: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
} else {
/* if we have shutdown listeners, accept4 could fail, and we
needn't notify users */
@ -232,8 +230,7 @@ static void on_read(void* arg, grpc_error* err) {
addr.len = static_cast<socklen_t>(sizeof(struct sockaddr_storage));
if (getsockname(fd, reinterpret_cast<struct sockaddr*>(addr.addr),
&(addr.len)) < 0) {
gpr_log(GPR_ERROR, "Failed getsockname: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Failed getsockname: %s", strerror(errno));
close(fd);
goto error;
}
@ -583,8 +580,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler {
if (getpeername(fd, reinterpret_cast<struct sockaddr*>(addr.addr),
&(addr.len)) < 0) {
gpr_log(GPR_ERROR, "Failed getpeername: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Failed getpeername: %s", strerror(errno));
close(fd);
return;
}

@ -57,7 +57,6 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/error.h"
@ -368,13 +367,11 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
}
if (grpc_set_socket_nonblocking(fd, 1) != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Unable to set nonblocking %d: %s", fd,
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unable to set nonblocking %d: %s", fd, strerror(errno));
goto error;
}
if (grpc_set_socket_cloexec(fd, 1) != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Unable to set cloexec %d: %s", fd,
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unable to set cloexec %d: %s", fd, strerror(errno));
goto error;
}
@ -416,8 +413,7 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
if (bind_socket(socket_factory, fd, addr) < 0) {
std::string addr_str = grpc_sockaddr_to_string(addr, false);
gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str.c_str(),
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str.c_str(), strerror(errno));
goto error;
}
@ -426,7 +422,7 @@ static int prepare_socket(grpc_socket_factory* socket_factory, int fd,
if (getsockname(fd, reinterpret_cast<grpc_sockaddr*>(sockname_temp.addr),
&sockname_temp.len) < 0) {
gpr_log(GPR_ERROR, "Unable to get the address socket %d is bound to: %s",
fd, grpc_core::StrError(errno).c_str());
fd, strerror(errno));
goto error;
}
@ -674,8 +670,7 @@ int grpc_udp_server_add_port(grpc_udp_server* s, grpc_resolved_address* addr,
GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
}
if (dsmode == GRPC_DSMODE_IPV4 &&
grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) {

@ -31,15 +31,13 @@
#include <grpc/support/log.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
static grpc_error* pipe_init(grpc_wakeup_fd* fd_info) {
int pipefd[2];
int r = pipe(pipefd);
if (0 != r) {
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno,
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno, strerror(errno));
return GRPC_OS_ERROR(errno, "pipe");
}
grpc_error* err;

@ -330,7 +330,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/gpr/log_posix.cc',
'src/core/lib/gpr/log_windows.cc',
'src/core/lib/gpr/murmur_hash.cc',
'src/core/lib/gpr/strerror.cc',
'src/core/lib/gpr/string.cc',
'src/core/lib/gpr/string_posix.cc',
'src/core/lib/gpr/string_util_windows.cc',

@ -41,7 +41,6 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
@ -161,8 +160,7 @@ static void session_read_cb(void* arg, /*session */
before notify_on_read is called. */
grpc_fd_notify_on_read(se->em_fd, &se->session_read_closure);
} else {
gpr_log(GPR_ERROR, "Unhandled read error %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unhandled read error %s", strerror(errno));
abort();
}
}
@ -328,7 +326,7 @@ static void client_session_write(void* arg, /*client */
}
gpr_mu_unlock(g_mu);
} else {
gpr_log(GPR_ERROR, "unknown errno %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "unknown errno %s", strerror(errno));
abort();
}
}

@ -40,7 +40,6 @@
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/resolve_address.h"
@ -458,7 +457,7 @@ int main(int argc, char** argv) {
test_no_op_with_port_and_start();
if (getifaddrs(&ifa) != 0 || ifa == nullptr) {
gpr_log(GPR_ERROR, "getifaddrs: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "getifaddrs: %s", strerror(errno));
return EXIT_FAILURE;
}
dst_addrs->naddrs = 0;

@ -38,7 +38,6 @@
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/error.h"
@ -81,8 +80,7 @@ static int read_bytes(int fd, char* buf, size_t read_size, int spin) {
if (errno == EAGAIN && spin == 1) {
continue;
}
gpr_log(GPR_ERROR, "Read failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
return -1;
}
} else {
@ -115,8 +113,7 @@ static int poll_read_bytes(int fd, char* buf, size_t read_size, int spin) {
if (errno == EINTR) {
continue;
} else {
gpr_log(GPR_ERROR, "Poll failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Poll failed: %s", strerror(errno));
return -1;
}
}
@ -127,7 +124,7 @@ static int poll_read_bytes(int fd, char* buf, size_t read_size, int spin) {
err2 = read(fd, buf + bytes_read, read_size - bytes_read);
} while (err2 < 0 && errno == EINTR);
if (err2 < 0 && errno != EAGAIN) {
gpr_log(GPR_ERROR, "Read failed: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
return -1;
}
bytes_read += static_cast<size_t>(err2);
@ -156,8 +153,7 @@ static int epoll_read_bytes(struct thread_args* args, char* buf, int spin) {
err = epoll_wait(args->epoll_fd, &ev, 1, spin ? 0 : -1);
if (err < 0) {
if (errno == EINTR) continue;
gpr_log(GPR_ERROR, "epoll_wait failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "epoll_wait failed: %s", strerror(errno));
return -1;
}
if (err == 0 && spin) continue;
@ -203,8 +199,7 @@ static int blocking_write_bytes(struct thread_args* args, char* buf) {
if (errno == EINTR) {
continue;
} else {
gpr_log(GPR_ERROR, "Read failed: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
return -1;
}
} else {
@ -242,7 +237,7 @@ static int epoll_setup(thread_args* args) {
set_socket_nonblocking(args);
epoll_fd = epoll_create(1);
if (epoll_fd < 0) {
gpr_log(GPR_ERROR, "epoll_create: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "epoll_create: %s", strerror(errno));
return -1;
}
@ -251,7 +246,7 @@ static int epoll_setup(thread_args* args) {
ev.events = EPOLLIN | EPOLLET;
ev.data.fd = args->fds.read_fd;
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, args->fds.read_fd, &ev) < 0) {
gpr_log(GPR_ERROR, "epoll_ctl: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "epoll_ctl: %s", strerror(errno));
}
return 0;
}
@ -335,8 +330,7 @@ error:
static int create_listening_socket(struct sockaddr* port, socklen_t len) {
int fd = socket(port->sa_family, SOCK_STREAM, 0);
if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
goto error;
}
@ -354,17 +348,17 @@ static int create_listening_socket(struct sockaddr* port, socklen_t len) {
}
if (bind(fd, port, len) < 0) {
gpr_log(GPR_ERROR, "bind: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "bind: %s", strerror(errno));
goto error;
}
if (listen(fd, 1) < 0) {
gpr_log(GPR_ERROR, "listen: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "listen: %s", strerror(errno));
goto error;
}
if (getsockname(fd, port, &len) < 0) {
gpr_log(GPR_ERROR, "getsockname: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "getsockname: %s", strerror(errno));
goto error;
}
@ -381,8 +375,7 @@ static int connect_client(struct sockaddr* addr, socklen_t len) {
int fd = socket(addr->sa_family, SOCK_STREAM, 0);
int err;
if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s",
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
goto error;
}
@ -400,7 +393,7 @@ static int connect_client(struct sockaddr* addr, socklen_t len) {
} while (err < 0 && errno == EINTR);
if (err < 0) {
gpr_log(GPR_ERROR, "connect error: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "connect error: %s", strerror(errno));
goto error;
}
return fd;
@ -415,7 +408,7 @@ error:
static int accept_server(int listen_fd) {
int fd = accept(listen_fd, nullptr, nullptr);
if (fd < 0) {
gpr_log(GPR_ERROR, "Accept failed: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "Accept failed: %s", strerror(errno));
return -1;
}
return fd;
@ -474,7 +467,7 @@ error:
static int create_sockets_socketpair(fd_pair* client_fds, fd_pair* server_fds) {
int fds[2];
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
gpr_log(GPR_ERROR, "socketpair: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "socketpair: %s", strerror(errno));
return -1;
}
@ -489,12 +482,12 @@ static int create_sockets_pipe(fd_pair* client_fds, fd_pair* server_fds) {
int cfds[2];
int sfds[2];
if (pipe(cfds) < 0) {
gpr_log(GPR_ERROR, "pipe: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "pipe: %s", strerror(errno));
return -1;
}
if (pipe(sfds) < 0) {
gpr_log(GPR_ERROR, "pipe: %s", grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "pipe: %s", strerror(errno));
return -1;
}

@ -45,7 +45,6 @@
#include <grpcpp/impl/codegen/service_type.h>
#include <grpcpp/server_builder.h>
#include "src/core/lib/gpr/strerror.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/thd.h"
@ -460,8 +459,7 @@ class FakeTcpServer {
gpr_log(GPR_ERROR,
"Fake TCP server encountered unexpected error:%d |%s| "
"sending %d bytes on fd:%d",
errno, grpc_core::StrError(errno).c_str(), bytes_to_send,
fd_);
errno, strerror(errno), bytes_to_send, fd_);
GPR_ASSERT(0);
} else if (bytes_sent > 0) {
total_bytes_sent_ += bytes_sent;

@ -34,7 +34,6 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/strerror.h"
#include "test/core/util/subprocess.h"
struct gpr_subprocess {
@ -59,8 +58,7 @@ gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
exec_args[argc] = nullptr;
execv(exec_args[0], exec_args);
/* if we reach here, an error has occurred */
gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0],
grpc_core::StrError(errno).c_str());
gpr_log(GPR_ERROR, "execv '%s' failed: %s", exec_args[0], strerror(errno));
_exit(1);
return nullptr;
} else {
@ -86,7 +84,7 @@ retry:
goto retry;
}
gpr_log(GPR_ERROR, "waitpid failed for pid %d: %s", p->pid,
grpc_core::StrError(errno).c_str());
strerror(errno));
return -1;
}
p->joined = true;

@ -1636,8 +1636,6 @@ src/core/lib/gpr/log_windows.cc \
src/core/lib/gpr/murmur_hash.cc \
src/core/lib/gpr/murmur_hash.h \
src/core/lib/gpr/spinlock.h \
src/core/lib/gpr/strerror.cc \
src/core/lib/gpr/strerror.h \
src/core/lib/gpr/string.cc \
src/core/lib/gpr/string.h \
src/core/lib/gpr/string_posix.cc \

@ -1475,8 +1475,6 @@ src/core/lib/gpr/log_windows.cc \
src/core/lib/gpr/murmur_hash.cc \
src/core/lib/gpr/murmur_hash.h \
src/core/lib/gpr/spinlock.h \
src/core/lib/gpr/strerror.cc \
src/core/lib/gpr/strerror.h \
src/core/lib/gpr/string.cc \
src/core/lib/gpr/string.h \
src/core/lib/gpr/string_posix.cc \

Loading…
Cancel
Save