|
|
@ -32,6 +32,7 @@ |
|
|
|
#include <grpcpp/impl/call.h> |
|
|
|
#include <grpcpp/impl/call.h> |
|
|
|
#include <grpcpp/support/time.h> |
|
|
|
#include <grpcpp/support/time.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "src/core/lib/gprpp/ref_counted.h" |
|
|
|
#include "src/core/lib/surface/call.h" |
|
|
|
#include "src/core/lib/surface/call.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace grpc { |
|
|
|
namespace grpc { |
|
|
@ -116,13 +117,7 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { |
|
|
|
done_intercepting_ = true; |
|
|
|
done_intercepting_ = true; |
|
|
|
if (!has_tag_) { |
|
|
|
if (!has_tag_) { |
|
|
|
/* We don't have a tag to return. */ |
|
|
|
/* We don't have a tag to return. */ |
|
|
|
std::unique_lock<std::mutex> lock(mu_); |
|
|
|
Unref(); |
|
|
|
if (--refs_ == 0) { |
|
|
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
|
|
grpc_call* call = call_.call(); |
|
|
|
|
|
|
|
delete this; |
|
|
|
|
|
|
|
grpc_call_unref(call); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
/* Start a dummy op so that we can return the tag */ |
|
|
|
/* Start a dummy op so that we can return the tag */ |
|
|
@ -142,8 +137,8 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { |
|
|
|
bool has_tag_; |
|
|
|
bool has_tag_; |
|
|
|
void* tag_; |
|
|
|
void* tag_; |
|
|
|
void* core_cq_tag_; |
|
|
|
void* core_cq_tag_; |
|
|
|
|
|
|
|
grpc_core::RefCount refs_; |
|
|
|
std::mutex mu_; |
|
|
|
std::mutex mu_; |
|
|
|
int refs_; |
|
|
|
|
|
|
|
bool finalized_; |
|
|
|
bool finalized_; |
|
|
|
int cancelled_; // This is an int (not bool) because it is passed to core
|
|
|
|
int cancelled_; // This is an int (not bool) because it is passed to core
|
|
|
|
bool done_intercepting_; |
|
|
|
bool done_intercepting_; |
|
|
@ -151,9 +146,7 @@ class ServerContext::CompletionOp final : public internal::CallOpSetInterface { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void ServerContext::CompletionOp::Unref() { |
|
|
|
void ServerContext::CompletionOp::Unref() { |
|
|
|
std::unique_lock<std::mutex> lock(mu_); |
|
|
|
if (refs_.Unref()) { |
|
|
|
if (--refs_ == 0) { |
|
|
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
|
|
grpc_call* call = call_.call(); |
|
|
|
grpc_call* call = call_.call(); |
|
|
|
delete this; |
|
|
|
delete this; |
|
|
|
grpc_call_unref(call); |
|
|
|
grpc_call_unref(call); |
|
|
@ -183,12 +176,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { |
|
|
|
*tag = tag_; |
|
|
|
*tag = tag_; |
|
|
|
ret = true; |
|
|
|
ret = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (--refs_ == 0) { |
|
|
|
Unref(); |
|
|
|
lock.unlock(); |
|
|
|
|
|
|
|
grpc_call* call = call_.call(); |
|
|
|
|
|
|
|
delete this; |
|
|
|
|
|
|
|
grpc_call_unref(call); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
finalized_ = true; |
|
|
|
finalized_ = true; |
|
|
@ -220,13 +208,7 @@ bool ServerContext::CompletionOp::FinalizeResult(void** tag, bool* status) { |
|
|
|
*tag = tag_; |
|
|
|
*tag = tag_; |
|
|
|
ret = true; |
|
|
|
ret = true; |
|
|
|
} |
|
|
|
} |
|
|
|
lock.lock(); |
|
|
|
Unref(); |
|
|
|
if (--refs_ == 0) { |
|
|
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
|
|
grpc_call* call = call_.call(); |
|
|
|
|
|
|
|
delete this; |
|
|
|
|
|
|
|
grpc_call_unref(call); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
/* There are interceptors to be run. Return false for now */ |
|
|
|
/* There are interceptors to be run. Return false for now */ |
|
|
|