Skip to content
Snippets Groups Projects
Commit 45a78af4 authored by Craig Tiller's avatar Craig Tiller
Browse files

Merge github.com:grpc/grpc into proxy-crash

parents 076f9784 791df44a
No related branches found
No related tags found
No related merge requests found
......@@ -280,6 +280,17 @@ class ClientContext {
/// There is no guarantee the call will be cancelled.
void TryCancel();
/// Global Callbacks
///
/// Can be set exactly once per application to install hooks whenever
/// a client context is constructed and destructed.
class GlobalCallbacks {
public:
virtual void DefaultConstructor(ClientContext* context) = 0;
virtual void Destructor(ClientContext* context) = 0;
};
static void SetGlobalCallbacks(GlobalCallbacks* callbacks);
private:
// Disallow copy and assign.
ClientContext(const ClientContext&);
......
......@@ -45,17 +45,31 @@
namespace grpc {
class DefaultGlobalClientCallbacks GRPC_FINAL
: public ClientContext::GlobalCallbacks {
public:
void DefaultConstructor(ClientContext* context) GRPC_OVERRIDE {}
void Destructor(ClientContext* context) GRPC_OVERRIDE {}
};
static DefaultGlobalClientCallbacks g_default_client_callbacks;
static ClientContext::GlobalCallbacks* g_client_callbacks =
&g_default_client_callbacks;
ClientContext::ClientContext()
: initial_metadata_received_(false),
call_(nullptr),
call_canceled_(false),
deadline_(gpr_inf_future(GPR_CLOCK_REALTIME)),
propagate_from_call_(nullptr) {}
propagate_from_call_(nullptr) {
g_client_callbacks->DefaultConstructor(this);
}
ClientContext::~ClientContext() {
if (call_) {
grpc_call_destroy(call_);
}
g_client_callbacks->Destructor(this);
}
std::unique_ptr<ClientContext> ClientContext::FromServerContext(
......@@ -124,4 +138,11 @@ grpc::string ClientContext::peer() const {
return peer;
}
void ClientContext::SetGlobalCallbacks(GlobalCallbacks* client_callbacks) {
GPR_ASSERT(g_client_callbacks == &g_default_client_callbacks);
GPR_ASSERT(client_callbacks != NULL);
GPR_ASSERT(client_callbacks != &g_default_client_callbacks);
g_client_callbacks = client_callbacks;
}
} // namespace grpc
......@@ -163,7 +163,7 @@ else:
setuptools.setup(
name='grpcio',
version='0.11.0b2',
version='0.12.0b0',
ext_modules=CYTHON_EXTENSION_MODULES,
packages=list(PACKAGES),
package_dir=PACKAGE_DIRECTORIES,
......
......@@ -33,7 +33,7 @@ set -ex
out=$(readlink -f ${1:-coverage})
root=$(readlink -f $(dirname $0)/../..)
shift
shift || true
tmp=$(mktemp)
cd $root
tools/run_tests/run_tests.py -c gcov -l c c++ $@ || true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment