Skip to content

Commit 0920f23

Browse files
author
root
committed
update
Signed-off-by: root <root@aio-node74-arm.cluster.local>
1 parent b54df69 commit 0920f23

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

internal/server/register.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,20 @@ func (ps *PluginServer) dial(unixSocketPath string, timeout time.Duration) (*grp
174174
return nil, fmt.Errorf("grpc.NewClient(%s): %w", target, err)
175175
}
176176

177-
// NewClient is non-blocking; block here to match the original WithBlock behaviour.
178-
if !c.WaitForStateChange(ctx, connectivity.Idle) {
179-
c.Close()
180-
return nil, fmt.Errorf("timed out waiting for connection to %s", unixSocketPath)
177+
c.Connect()
178+
for {
179+
state := c.GetState()
180+
if state == connectivity.Ready {
181+
return c, nil
182+
}
183+
if state == connectivity.TransientFailure || state == connectivity.Shutdown {
184+
c.Close()
185+
return nil, fmt.Errorf("connection to %s failed (state: %s)", unixSocketPath, state)
186+
}
187+
// Block until the state changes or the deadline is exceeded.
188+
if !c.WaitForStateChange(ctx, state) {
189+
c.Close()
190+
return nil, fmt.Errorf("timed out waiting for connection to %s", unixSocketPath)
191+
}
181192
}
182-
183-
return c, nil
184193
}

0 commit comments

Comments
 (0)