Skip to content

Commit

Permalink
messenger: stop using deprecated mem_fun
Browse files Browse the repository at this point in the history
When building against LLVM 9's libc++, we get a warning about using a
deprecated function. Seems like mem_fn is the appropriate replacement.

../../src/kudu/rpc/messenger.cc:238:48: warning: 'mem_fun<void, kudu::rpc::Messenger>' is deprecated [-Wdeprecated-declarations]
  *msgr = shared_ptr<Messenger>(new_msgr, std::mem_fun(&Messenger::AllExternalReferencesDropped));
                                               ^
../../thirdparty/installed/tsan/include/c++/v1/functional:1148:1: note: 'mem_fun<void, kudu::rpc::Messenger>' has been explicitly marked deprecated here
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
../../thirdparty/installed/tsan/include/c++/v1/__config:944:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX11'
                                      ^
../../thirdparty/installed/tsan/include/c++/v1/__config:933:48: note: expanded from macro '_LIBCPP_DEPRECATED'
                                               ^
1 warning generated.

Change-Id: Ife57c52050ba19a07218694c84989fa16f1dd341
Reviewed-on: http://gerrit.cloudera.org:8080/14834
Reviewed-by: Alexey Serbin <[email protected]>
Reviewed-by: Grant Henke <[email protected]>
Tested-by: Adar Dembo <[email protected]>
  • Loading branch information
adembo committed Dec 5, 2019
1 parent 83f65ff commit dd2682c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
17 changes: 7 additions & 10 deletions src/kudu/rpc/messenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "kudu/util/metrics.h"
#include "kudu/util/monotime.h"
#include "kudu/util/net/socket.h"
#include "kudu/util/scoped_cleanup.h"
#include "kudu/util/status.h"
#include "kudu/util/thread_restrictions.h"
#include "kudu/util/threadpool.h"
Expand Down Expand Up @@ -184,15 +183,15 @@ MessengerBuilder& MessengerBuilder::set_reuseport() {
return *this;
}

Status MessengerBuilder::Build(shared_ptr<Messenger> *msgr) {
Status MessengerBuilder::Build(shared_ptr<Messenger>* msgr) {
// Initialize SASL library before we start making requests
RETURN_NOT_OK(SaslInit(!keytab_file_.empty()));

Messenger* new_msgr(new Messenger(*this));

auto cleanup = MakeScopedCleanup([&] () {
new_msgr->AllExternalReferencesDropped();
});
// See docs on Messenger::retain_self_ for info about this odd hack.
//
// Note: can't use make_shared() as it doesn't support custom deleters.
shared_ptr<Messenger> new_msgr(new Messenger(*this),
std::mem_fn(&Messenger::AllExternalReferencesDropped));

RETURN_NOT_OK(ParseTriState("--rpc_authentication",
rpc_authentication_,
Expand Down Expand Up @@ -233,9 +232,7 @@ Status MessengerBuilder::Build(shared_ptr<Messenger> *msgr) {
}
}

// See docs on Messenger::retain_self_ for info about this odd hack.
cleanup.cancel();
*msgr = shared_ptr<Messenger>(new_msgr, std::mem_fun(&Messenger::AllExternalReferencesDropped));
*msgr = std::move(new_msgr);
return Status::OK();
}

Expand Down
7 changes: 4 additions & 3 deletions src/kudu/rpc/messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
#include <mutex>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#include <boost/optional/optional.hpp>
#include <gtest/gtest_prod.h>

#include "kudu/gutil/macros.h"
#include "kudu/gutil/gscoped_ptr.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/ref_counted.h"
#include "kudu/rpc/connection.h"
#include "kudu/rpc/rpc_service.h"
#include "kudu/security/security_flags.h"
#include "kudu/security/token.pb.h"
#include "kudu/util/locks.h"
Expand Down Expand Up @@ -65,7 +67,6 @@ class InboundCall;
class Messenger;
class OutboundCall;
class Reactor;
class RpcService;
class RpczStore;

struct AcceptorPoolInfo {
Expand Down Expand Up @@ -165,7 +166,7 @@ class MessengerBuilder {
// Configure the messenger to set the SO_REUSEPORT socket option.
MessengerBuilder& set_reuseport();

Status Build(std::shared_ptr<Messenger> *msgr);
Status Build(std::shared_ptr<Messenger>* msgr);

private:
const std::string name_;
Expand Down

0 comments on commit dd2682c

Please sign in to comment.