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 "test/core/util/test_config.h" 21 22 int main(int argc, char** argv) { 23 grpc_completion_queue* cq1; 24 grpc_completion_queue* cq2; 25 grpc_completion_queue* cq3; 26 grpc_completion_queue_attributes attr; 27 28 grpc_server* server; 29 30 grpc_test_init(argc, argv); 31 grpc_init(); 32 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( 37 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); 38 39 attr.cq_polling_type = GRPC_CQ_NON_LISTENING; 40 cq2 = grpc_completion_queue_create( 41 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); 42 43 attr.cq_polling_type = GRPC_CQ_NON_POLLING; 44 cq3 = grpc_completion_queue_create( 45 grpc_completion_queue_factory_lookup(&attr), &attr, nullptr); 46 47 server = grpc_server_create(nullptr, nullptr); 48 grpc_server_register_completion_queue(server, cq1, nullptr); 49 grpc_server_add_insecure_http2_port(server, "[::]:0"); 50 grpc_server_register_completion_queue(server, cq2, nullptr); 51 grpc_server_register_completion_queue(server, cq3, nullptr); 52 53 grpc_server_start(server); 54 grpc_server_shutdown_and_notify(server, cq2, nullptr); 55 grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), 56 nullptr); /* cue queue hang */ 57 grpc_completion_queue_shutdown(cq1); 58 grpc_completion_queue_shutdown(cq2); 59 grpc_completion_queue_shutdown(cq3); 60 61 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); 64 65 grpc_server_destroy(server); 66 grpc_completion_queue_destroy(cq1); 67 grpc_completion_queue_destroy(cq2); 68 grpc_completion_queue_destroy(cq3); 69 grpc_shutdown(); 70 return 0; 71 } 72