Merge pull request #21845 from veblush/absl-str-format

Replaced gpr_asprintf with absl::StrFormat
pull/22095/head
Esun Kim 5 years ago committed by GitHub
commit 056a3bc884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 1
      BUILD.gn
  3. 13
      CMakeLists.txt
  4. 6
      Makefile
  5. 1
      build.yaml
  6. 7
      config.m4
  7. 7
      config.w32
  8. 1
      gRPC-C++.podspec
  9. 1
      gRPC-Core.podspec
  10. 14
      grpc.gemspec
  11. 1
      grpc.gyp
  12. 14
      package.xml
  13. 9
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  14. 10
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  15. 6
      src/python/grpcio/grpc_core_dependencies.py

@ -558,6 +558,7 @@ grpc_cc_library(
external_deps = [
"absl/memory",
"absl/strings",
"absl/strings:str_format",
],
language = "c++",
public_hdrs = GPR_PUBLIC_HDRS,

@ -163,6 +163,7 @@ config("grpc_config") {
deps = [
":absl/container:inlined_vector",
":absl/memory:memory",
":absl/strings:str_format",
":absl/strings:strings",
":absl/types:optional",
]

@ -119,6 +119,8 @@ set(gRPC_ABSL_USED_TARGETS
absl_raw_logging_internal
absl_span
absl_spinlock_wait
absl_str_format
absl_str_format_internal
absl_strings
absl_strings_internal
absl_throw_delegate
@ -1440,6 +1442,7 @@ target_link_libraries(gpr
${_gRPC_ALLTARGETS_LIBRARIES}
absl::inlined_vector
absl::memory
absl::str_format
absl::strings
absl::optional
)
@ -18572,7 +18575,7 @@ generate_pkgconfig(
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
""
"-lgpr -labsl_bad_optional_access -labsl_strings -labsl_strings_internal -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
"-lgpr -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
""
"gpr.pc")
@ -18582,7 +18585,7 @@ generate_pkgconfig(
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"gpr openssl"
"-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_bad_optional_access -labsl_strings -labsl_strings_internal -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
"-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
""
"grpc.pc")
@ -18592,7 +18595,7 @@ generate_pkgconfig(
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"gpr"
"-lgrpc_unsecure -labsl_bad_optional_access -labsl_strings -labsl_strings_internal -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
"-lgrpc_unsecure -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
""
"grpc_unsecure.pc")
@ -18602,7 +18605,7 @@ generate_pkgconfig(
"C++ wrapper for gRPC"
"${PACKAGE_VERSION}"
"grpc"
"-lgrpc++ -labsl_bad_optional_access -labsl_strings -labsl_strings_internal -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
"-lgrpc++ -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
""
"grpc++.pc")
@ -18612,6 +18615,6 @@ generate_pkgconfig(
"C++ wrapper for gRPC without SSL"
"${PACKAGE_VERSION}"
"grpc_unsecure"
"-lgrpc++_unsecure -labsl_bad_optional_access -labsl_strings -labsl_strings_internal -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
"-lgrpc++_unsecure -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity"
""
"grpc++_unsecure.pc")

@ -9089,6 +9089,12 @@ LIBGRPC_ABSEIL_SRC = \
third_party/abseil-cpp/absl/strings/internal/escaping.cc \
third_party/abseil-cpp/absl/strings/internal/memutil.cc \
third_party/abseil-cpp/absl/strings/internal/ostringstream.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/output.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc \
third_party/abseil-cpp/absl/strings/internal/utf8.cc \
third_party/abseil-cpp/absl/strings/match.cc \
third_party/abseil-cpp/absl/strings/numbers.cc \

@ -272,6 +272,7 @@ filegroups:
deps:
- absl/container:inlined_vector
- absl/memory:memory
- absl/strings:str_format
- absl/strings:strings
- absl/types:optional
uses:

@ -489,6 +489,12 @@ if test "$PHP_GRPC" != "no"; then
third_party/abseil-cpp/absl/strings/internal/escaping.cc \
third_party/abseil-cpp/absl/strings/internal/memutil.cc \
third_party/abseil-cpp/absl/strings/internal/ostringstream.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/output.cc \
third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc \
third_party/abseil-cpp/absl/strings/internal/utf8.cc \
third_party/abseil-cpp/absl/strings/match.cc \
third_party/abseil-cpp/absl/strings/numbers.cc \
@ -882,6 +888,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/numeric)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal/str_format)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/types)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/address_sorting)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl-with-bazel)

@ -458,6 +458,12 @@ if (PHP_GRPC != "no") {
"third_party\\abseil-cpp\\absl\\strings\\internal\\escaping.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\memutil.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\ostringstream.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\arg.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\bind.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\extension.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\float_conversion.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\output.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\str_format\\parser.cc " +
"third_party\\abseil-cpp\\absl\\strings\\internal\\utf8.cc " +
"third_party\\abseil-cpp\\absl\\strings\\match.cc " +
"third_party\\abseil-cpp\\absl\\strings\\numbers.cc " +
@ -916,6 +922,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\numeric");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal\\str_format");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\types");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\address_sorting");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl-with-bazel");

@ -216,6 +216,7 @@ Pod::Spec.new do |s|
abseil_version = '0.20190808.1'
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/types/optional', abseil_version

@ -176,6 +176,7 @@ Pod::Spec.new do |s|
abseil_version = '0.20190808.1'
ss.dependency 'abseil/container/inlined_vector', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/strings/str_format', abseil_version
ss.dependency 'abseil/strings/strings', abseil_version
ss.dependency 'abseil/types/optional', abseil_version
ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS'

@ -965,6 +965,19 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/strings/internal/ostringstream.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/arg.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/bind.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/checker.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/extension.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/output.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/output.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_format/parser.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_join_internal.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/str_split_internal.h )
s.files += %w( third_party/abseil-cpp/absl/strings/internal/utf8.cc )
@ -975,6 +988,7 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/strings/numbers.h )
s.files += %w( third_party/abseil-cpp/absl/strings/str_cat.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/str_cat.h )
s.files += %w( third_party/abseil-cpp/absl/strings/str_format.h )
s.files += %w( third_party/abseil-cpp/absl/strings/str_join.h )
s.files += %w( third_party/abseil-cpp/absl/strings/str_replace.cc )
s.files += %w( third_party/abseil-cpp/absl/strings/str_replace.h )

@ -443,6 +443,7 @@
'dependencies': [
'absl/container:inlined_vector',
'absl/memory:memory',
'absl/strings:str_format',
'absl/strings:strings',
'absl/types:optional',
],

@ -970,6 +970,19 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/ostringstream.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/arg.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/bind.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/checker.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/extension.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/output.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/output.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_format/parser.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_join_internal.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/str_split_internal.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/internal/utf8.cc" role="src" />
@ -980,6 +993,7 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/numbers.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_cat.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_cat.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_format.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_join.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_replace.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/strings/str_replace.h" role="src" />

@ -31,6 +31,8 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include "absl/strings/str_format.h"
#include "src/core/ext/filters/http/server/http_server_filter.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
@ -413,14 +415,9 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
arg = grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ);
if (grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT)) {
char* socket_name = nullptr;
gpr_asprintf(&socket_name, "chttp2 listener %s", addr);
state->channelz_listen_socket =
grpc_core::MakeRefCounted<grpc_core::channelz::ListenSocketNode>(
addr, socket_name);
// TODO(veblush): Remove this once gpr_asprintf is replaced by
// absl::StrFormat
gpr_free(socket_name);
addr, absl::StrFormat("chttp2 listener %s", addr));
}
/* Register with the server only upon success */

@ -31,6 +31,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "absl/strings/str_format.h"
#include "src/core/ext/transport/chttp2/transport/context_list.h"
#include "src/core/ext/transport/chttp2/transport/frame_data.h"
#include "src/core/ext/transport/chttp2/transport/internal.h"
@ -378,14 +380,10 @@ static bool read_channel_args(grpc_chttp2_transport* t,
if (channelz_enabled) {
// TODO(ncteisen): add an API to endpoint to query for local addr, and pass
// it in here, so SocketNode knows its own address.
char* socket_name = nullptr;
gpr_asprintf(&socket_name, "%s %s", get_vtable()->name, t->peer_string);
t->channelz_socket =
grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>(
"", t->peer_string, socket_name);
// TODO(veblush): Remove this once gpr_asprintf is replaced by
// absl::StrFormat
gpr_free(socket_name);
"", t->peer_string,
absl::StrFormat("%s %s", get_vtable()->name, t->peer_string));
}
return enable_bdp;
}

@ -457,6 +457,12 @@ CORE_SOURCE_FILES = [
'third_party/abseil-cpp/absl/strings/internal/escaping.cc',
'third_party/abseil-cpp/absl/strings/internal/memutil.cc',
'third_party/abseil-cpp/absl/strings/internal/ostringstream.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/output.cc',
'third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc',
'third_party/abseil-cpp/absl/strings/internal/utf8.cc',
'third_party/abseil-cpp/absl/strings/match.cc',
'third_party/abseil-cpp/absl/strings/numbers.cc',

Loading…
Cancel
Save