X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=grpc-proxy%2Fmain-grpc.cpp;h=545b40fa294107522e11f294b237eb49ab3fd3a3;hb=be197db866b8da802dceb55b460055edc16fcc86;hp=ea7572213257724c3d8d6de7a3f92a0d22e22ac4;hpb=53b470c60986fcfc83dc3a5eafcd9370a7264086;p=src%2Fagl-compositor.git diff --git a/grpc-proxy/main-grpc.cpp b/grpc-proxy/main-grpc.cpp index ea75722..545b40f 100644 --- a/grpc-proxy/main-grpc.cpp +++ b/grpc-proxy/main-grpc.cpp @@ -437,7 +437,7 @@ register_shell_init(void) clock_gettime(CLOCK_MONOTONIC, &ts); ts.tv_sec = 0; - ts.tv_nsec = 250 * 1000 * 1000; // 250 ms + ts.tv_nsec = 50 * 1000 * 1000; // 50 ms // verify if 'bound_fail' was received while (true) { @@ -542,8 +542,19 @@ err: } static void -start_grpc_server(Shell *aglShell) +start_grpc_server(std::shared_ptr server) { + LOG("gRPC server listening\n"); + server->Wait(); +} + +int main(int argc, char **argv) +{ + (void) argc; + (void) argv; + Shell *aglShell = nullptr; + int ret = 0; + // instantiante the grpc server std::string server_address(kDefaultGrpcServiceAddress); GrpcServiceImpl service{aglShell}; @@ -555,18 +566,8 @@ start_grpc_server(Shell *aglShell) builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); builder.RegisterService(&service); - std::unique_ptr server(builder.BuildAndStart()); - LOG("gRPC server listening on %s\n", server_address.c_str()); - - server->Wait(); -} - -int main(int argc, char **argv) -{ - (void) argc; - (void) argv; - Shell *aglShell; - int ret = 0; + std::shared_ptr server(builder.BuildAndStart()); + std::thread thread(start_grpc_server, server); // this blocks until we detect that another shell client started // running @@ -581,7 +582,8 @@ int main(int argc, char **argv) std::shared_ptr agl_shell{sh->shell, agl_shell_destroy}; aglShell = new Shell(agl_shell, sh); - std::thread thread(start_grpc_server, aglShell); + // now that we have aglShell, set it to the gRPC proxy as well + service.setAglShell(aglShell); // serve wayland requests while (running && ret != -1) {