Merge pull request 'Always reset persister in handler' (#194) from lash/no-persister-deadlock into master

Reviewed-on: urdt/ussd#194
This commit is contained in:
lash 2024-12-02 16:17:36 +01:00
commit da462346f9

View File

@ -114,6 +114,9 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
logg.WarnCtxf(ctx, "handler init called before it is ready or more than once", "state", h.st, "cache", h.ca)
return r, nil
}
defer func() {
h.pe = nil
}()
h.st = h.pe.GetState()
h.ca = h.pe.GetMemory()
@ -133,7 +136,6 @@ func (h *Handlers) Init(ctx context.Context, sym string, input []byte) (resource
logg.ErrorCtxf(ctx, "perister fail in handler", "state", h.st, "cache", h.ca)
return r, fmt.Errorf("cannot get state and memory for handler")
}
h.pe = nil
logg.DebugCtxf(ctx, "handler has been initialized", "state", h.st, "cache", h.ca)