1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18
19 #include <grpc/grpc.h>
20 #include <grpc/grpc_security.h>
21 #include <grpc/support/time.h>
22
23 #include "test/core/util/test_config.h"
24
main(int argc,char ** argv)25 int main(int argc, char** argv) {
26 grpc_completion_queue* cq1;
27 grpc_completion_queue* cq2;
28 grpc_completion_queue* cq3;
29 grpc_completion_queue_attributes attr;
30
31 grpc_server* server;
32
33 grpc::testing::TestEnvironment env(&argc, argv);
34 grpc_init();
35
36 attr.version = 1;
37 attr.cq_completion_type = GRPC_CQ_NEXT;
38 attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING;
39 cq1 = grpc_completion_queue_create(
40 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
41
42 attr.cq_polling_type = GRPC_CQ_NON_LISTENING;
43 cq2 = grpc_completion_queue_create(
44 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
45
46 attr.cq_polling_type = GRPC_CQ_NON_POLLING;
47 cq3 = grpc_completion_queue_create(
48 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
49
50 server = grpc_server_create(nullptr, nullptr);
51 grpc_server_register_completion_queue(server, cq1, nullptr);
52 grpc_server_credentials* server_creds =
53 grpc_insecure_server_credentials_create();
54 grpc_server_add_http2_port(server, "[::]:0", server_creds);
55 grpc_server_credentials_release(server_creds);
56 grpc_server_register_completion_queue(server, cq2, nullptr);
57 grpc_server_register_completion_queue(server, cq3, nullptr);
58
59 grpc_server_start(server);
60 grpc_server_shutdown_and_notify(server, cq2, nullptr);
61 grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME),
62 nullptr); // cue queue freeze
63 grpc_completion_queue_shutdown(cq1);
64 grpc_completion_queue_shutdown(cq2);
65 grpc_completion_queue_shutdown(cq3);
66
67 grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
68 grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
69 grpc_completion_queue_next(cq3, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
70
71 grpc_server_destroy(server);
72 grpc_completion_queue_destroy(cq1);
73 grpc_completion_queue_destroy(cq2);
74 grpc_completion_queue_destroy(cq3);
75 grpc_shutdown();
76 return 0;
77 }
78