X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=grpc-proxy%2Fmain-grpc.cpp;h=545b40fa294107522e11f294b237eb49ab3fd3a3;hb=be197db866b8da802dceb55b460055edc16fcc86;hp=a8c1c5e4a7158daebffcdc8039a1fa1fd0d71a50;hpb=994d8a30b27f05516f6dc0a9f949315241cb9cc0;p=src%2Fagl-compositor.git diff --git a/grpc-proxy/main-grpc.cpp b/grpc-proxy/main-grpc.cpp index a8c1c5e..545b40f 100644 --- a/grpc-proxy/main-grpc.cpp +++ b/grpc-proxy/main-grpc.cpp @@ -129,7 +129,7 @@ agl_shell_app_on_output(void *data, struct agl_shell *agl_shell, (void) data; (void) app_id; - LOG("got app_on_output event app_id %s on output\n", app_id, output_name); + LOG("got app_on_output event app_id %s on output %s\n", app_id, output_name); } @@ -387,7 +387,8 @@ __register_shell_init(void) wl_display = wl_display_connect(NULL); if (!wl_display) { - goto err; + ret = -1; + goto err_failed_display; } registry = wl_display_get_registry(wl_display); sh->wait_for_bound = true; @@ -416,6 +417,8 @@ __register_shell_init(void) err: wl_registry_destroy(registry); wl_display_disconnect(wl_display); + +err_failed_display: delete sh; return ret; } @@ -434,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) { @@ -539,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}; @@ -552,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 @@ -578,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) {