|
|
|
@ -67,10 +67,10 @@ namespace { |
|
|
|
|
void* tag(int i) { return (void*)(intptr_t)i; } |
|
|
|
|
|
|
|
|
|
#ifdef GPR_POSIX_SOCKET |
|
|
|
|
static int assert_non_blocking_poll(struct pollfd* pfds, nfds_t nfds, |
|
|
|
|
static int non_blocking_poll(struct pollfd* pfds, nfds_t nfds, |
|
|
|
|
int timeout) { |
|
|
|
|
GPR_ASSERT(timeout == 0); |
|
|
|
|
return poll(pfds, nfds, timeout); |
|
|
|
|
/* ignore timeout and always use timeout 0 */ |
|
|
|
|
return poll(pfds, nfds, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class PollOverride { |
|
|
|
@ -89,7 +89,7 @@ class PollOverride { |
|
|
|
|
class PollingOverrider : public PollOverride { |
|
|
|
|
public: |
|
|
|
|
explicit PollingOverrider(bool allow_blocking) |
|
|
|
|
: PollOverride(allow_blocking ? poll : assert_non_blocking_poll) {} |
|
|
|
|
: PollOverride(allow_blocking ? poll : non_blocking_poll) {} |
|
|
|
|
}; |
|
|
|
|
#else |
|
|
|
|
class PollingOverrider { |
|
|
|
@ -180,9 +180,11 @@ class Verifier { |
|
|
|
|
|
|
|
|
|
class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { |
|
|
|
|
protected: |
|
|
|
|
AsyncEnd2endTest(): poll_override_(GetParam()) {} |
|
|
|
|
AsyncEnd2endTest() {} |
|
|
|
|
|
|
|
|
|
void SetUp() GRPC_OVERRIDE { |
|
|
|
|
poll_overrider_.reset(new PollingOverrider(!GetParam())); |
|
|
|
|
|
|
|
|
|
int port = grpc_pick_unused_port_or_die(); |
|
|
|
|
server_address_ << "localhost:" << port; |
|
|
|
|
|
|
|
|
@ -202,6 +204,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { |
|
|
|
|
cq_->Shutdown(); |
|
|
|
|
while (cq_->Next(&ignored_tag, &ignored_ok)) |
|
|
|
|
; |
|
|
|
|
poll_overrider_.reset(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ResetStub() { |
|
|
|
@ -250,7 +253,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { |
|
|
|
|
grpc::testing::EchoTestService::AsyncService service_; |
|
|
|
|
std::ostringstream server_address_; |
|
|
|
|
|
|
|
|
|
PollingOverrider poll_override_; |
|
|
|
|
std::unique_ptr<PollingOverrider> poll_overrider_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_P(AsyncEnd2endTest, SimpleRpc) { |
|
|
|
@ -1089,7 +1092,7 @@ class AsyncEnd2endServerTryCancelTest : public AsyncEnd2endTest { |
|
|
|
|
Verifier(GetParam()).Expect(7, true).Verify(cq_.get()); |
|
|
|
|
|
|
|
|
|
// This is expected to fail in all cases i.e for all values of
|
|
|
|
|
// server_try_cancel. This is becasue at this point, either there are no
|
|
|
|
|
// server_try_cancel. This is because at this point, either there are no
|
|
|
|
|
// more msgs from the client (because client called WritesDone) or the RPC
|
|
|
|
|
// is cancelled on the server
|
|
|
|
|
srv_stream.Read(&recv_request, tag(8)); |
|
|
|
|