blob: dfa3b48b52d3cedb47621d1951bcb0a5a713125d [file] [log] [blame]
Craig Tiller052d27b2015-06-26 08:11:34 -07001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Craig Tiller052d27b2015-06-26 08:11:34 -07004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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
Craig Tiller052d27b2015-06-26 08:11:34 -07008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller052d27b2015-06-26 08:11:34 -070010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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.
Craig Tiller052d27b2015-06-26 08:11:34 -070016 *
17 */
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070018
Craig Tiller052d27b2015-06-26 08:11:34 -070019#include <grpc/grpc.h>
20#include "test/core/util/test_config.h"
21
Craig Tillerbaa14a92017-11-03 09:09:36 -070022int main(int argc, char** argv) {
23 grpc_completion_queue* cq1;
24 grpc_completion_queue* cq2;
25 grpc_completion_queue* cq3;
Sree Kuchibhotlab5b6bfd2017-03-22 02:32:01 -070026 grpc_completion_queue_attributes attr;
27
Craig Tillerbaa14a92017-11-03 09:09:36 -070028 grpc_server* server;
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070029
Craig Tiller052d27b2015-06-26 08:11:34 -070030 grpc_test_init(argc, argv);
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070031 grpc_init();
Sree Kuchibhotlab5b6bfd2017-03-22 02:32:01 -070032
33 attr.version = 1;
34 attr.cq_completion_type = GRPC_CQ_NEXT;
35 attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING;
36 cq1 = grpc_completion_queue_create(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080037 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
Sree Kuchibhotlab5b6bfd2017-03-22 02:32:01 -070038
39 attr.cq_polling_type = GRPC_CQ_NON_LISTENING;
40 cq2 = grpc_completion_queue_create(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080041 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
Sree Kuchibhotlab5b6bfd2017-03-22 02:32:01 -070042
43 attr.cq_polling_type = GRPC_CQ_NON_POLLING;
44 cq3 = grpc_completion_queue_create(
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080045 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080046
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080047 server = grpc_server_create(nullptr, nullptr);
48 grpc_server_register_completion_queue(server, cq1, nullptr);
Craig Tillerc5ae3eb2015-08-03 10:42:22 -070049 grpc_server_add_insecure_http2_port(server, "[::]:0");
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080050 grpc_server_register_completion_queue(server, cq2, nullptr);
51 grpc_server_register_completion_queue(server, cq3, nullptr);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080052
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070053 grpc_server_start(server);
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080054 grpc_server_shutdown_and_notify(server, cq2, nullptr);
Craig Tillerd6c98df2015-08-18 09:33:44 -070055 grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME),
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080056 nullptr); /* cue queue hang */
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070057 grpc_completion_queue_shutdown(cq1);
58 grpc_completion_queue_shutdown(cq2);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080059 grpc_completion_queue_shutdown(cq3);
60
Craig Tiller4ac2b8e2017-11-10 14:14:17 -080061 grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
62 grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
63 grpc_completion_queue_next(cq3, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080064
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070065 grpc_server_destroy(server);
Craig Tiller93305a52015-07-01 06:57:23 -070066 grpc_completion_queue_destroy(cq1);
67 grpc_completion_queue_destroy(cq2);
Sree Kuchibhotla321881d2017-02-27 11:25:28 -080068 grpc_completion_queue_destroy(cq3);
Masood Malekghassemi1aa041a2015-06-25 18:02:18 -070069 grpc_shutdown();
70 return 0;
71}