X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=grpc-proxy%2Fmain-grpc.cpp;h=2f9350a01a41d0ea1329f8203410348127120d8b;hb=73e82a6f346d2835f6d6b0752629b2d2446e871d;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..2f9350a 100644 --- a/grpc-proxy/main-grpc.cpp +++ b/grpc-proxy/main-grpc.cpp @@ -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) {