From 2e4128dcfece542a7fcd98d14d3a7e7f942bb22a Mon Sep 17 00:00:00 2001 From: Romain LE JEUNE Date: Tue, 26 Jul 2022 09:27:45 +0200 Subject: [PATCH] GODT-1746: wait until frontend is ready --- internal/frontend/grpc/service.go | 8 +++++++- internal/frontend/grpc/service_methods.go | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/frontend/grpc/service.go b/internal/frontend/grpc/service.go index 86f57d50..3f1e81a8 100644 --- a/internal/frontend/grpc/service.go +++ b/internal/frontend/grpc/service.go @@ -113,6 +113,10 @@ func NewService( firstTimeAutostart: sync.Once{}, } + // Initializing.Done is only called sync.Once. Please keep the increment + // set to 1 + s.initializing.Add(1) + config, err := tls.GetConfig() config.ClientAuth = cryptotls.NoClientCert // skip client auth if the certificate allow it. if err != nil { @@ -191,7 +195,9 @@ func (s *Service) NotifySilentUpdateError(err error) { _ = s.SendEvent(NewUpdateErrorEvent(UpdateErrorType_UPDATE_SILENT_ERROR)) } -func (s *Service) WaitUntilFrontendIsReady() {} +func (s *Service) WaitUntilFrontendIsReady() { + s.initializing.Wait() +} func (s *Service) watchEvents() { // nolint:funlen if s.bridge.HasError(bridge.ErrLocalCacheUnavailable) { diff --git a/internal/frontend/grpc/service_methods.go b/internal/frontend/grpc/service_methods.go index a35e4c51..1f7dba3f 100644 --- a/internal/frontend/grpc/service_methods.go +++ b/internal/frontend/grpc/service_methods.go @@ -69,7 +69,8 @@ func (s *Service) AddLogEntry(_ context.Context, request *AddLogEntryRequest) (* // GuiReady implement the GuiReady gRPC service call. func (s *Service) GuiReady(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { s.log.Info("GuiReady") - // Note nothing to be done. old Qt frontend had a sync.one + // sync.one + s.initializationDone.Do(s.initializing.Done) return &emptypb.Empty{}, nil }