File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,13 +106,23 @@ func (r *Registry) GetGuardInfo() map[string]string {
106106// Close closes all registered guards that implement Close(context.Context) error.
107107// It should be called during server shutdown to release WASM runtime resources.
108108func (r * Registry ) Close (ctx context.Context ) {
109+ type closableGuard struct {
110+ id string
111+ c interface { Close (context.Context ) error }
112+ }
113+
109114 r .mu .Lock ()
110- defer r . mu . Unlock ( )
115+ closers := make ([] closableGuard , 0 , len ( r . guards ) )
111116 for id , g := range r .guards {
112117 if c , ok := g .(interface { Close (context.Context ) error }); ok {
113- if err := c .Close (ctx ); err != nil {
114- logger .LogWarn ("guard" , "Failed to close guard for server %s: %v" , id , err )
115- }
118+ closers = append (closers , closableGuard {id : id , c : c })
119+ }
120+ }
121+ r .mu .Unlock ()
122+
123+ for _ , guard := range closers {
124+ if err := guard .c .Close (ctx ); err != nil {
125+ logger .LogWarn ("guard" , "Failed to close guard for server %s: %v" , guard .id , err )
116126 }
117127 }
118128}
You can’t perform that action at this time.
0 commit comments