Commit 9bffea4 1 parent a47ea0d commit 9bffea4 Copy full SHA for 9bffea4
File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -265,7 +265,10 @@ func (c *Client) Close() error {
265
265
266
266
func (c * Client ) reconnect (ctx context.Context ) error {
267
267
// fmt.Println("Reconnecting")
268
- c .conn .Close ()
268
+ if c .conn != nil {
269
+ c .conn .Close ()
270
+ c .conn = nil
271
+ }
269
272
stream , err := c .dialer (ctx )
270
273
if err != nil {
271
274
return err
@@ -277,6 +280,11 @@ func (c *Client) reconnect(ctx context.Context) error {
277
280
func (c * Client ) doRountrip (ctx context.Context , msg * kmip.RequestMessage ) (* kmip.ResponseMessage , error ) {
278
281
c .lock .Lock ()
279
282
defer c .lock .Unlock ()
283
+ if c .conn == nil {
284
+ if err := c .reconnect (ctx ); err != nil {
285
+ return nil , err
286
+ }
287
+ }
280
288
281
289
//TODO: Better reconnection loop. Do we really need a retry counter here ?
282
290
retry := 3
You can’t perform that action at this time.
0 commit comments