Merge pull request #17573 from yang-g/socket_mutator

Correctly reference the internal string for socket mutator arg
pull/17583/head
Yang Gao 6 years ago committed by GitHub
commit 806c1e0b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/cpp/common/channel_arguments.cc
  2. 3
      test/cpp/common/channel_arguments_test.cc

@ -106,7 +106,9 @@ void ChannelArguments::SetSocketMutator(grpc_socket_mutator* mutator) {
}
if (!replaced) {
strings_.push_back(grpc::string(mutator_arg.key));
args_.push_back(mutator_arg);
args_.back().key = const_cast<char*>(strings_.back().c_str());
}
}

@ -209,6 +209,9 @@ TEST_F(ChannelArgumentsTest, SetSocketMutator) {
channel_args_.SetSocketMutator(mutator0);
EXPECT_TRUE(HasArg(arg0));
// Exercise the copy constructor because we ran some sanity checks in it.
grpc::ChannelArguments new_args{channel_args_};
channel_args_.SetSocketMutator(mutator1);
EXPECT_TRUE(HasArg(arg1));
// arg0 is replaced by arg1

Loading…
Cancel
Save