mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
embed: deep copy user handlers
Shallow copy of user handlers leads to a nil map assignment when enabling pprof. Since the map is being modified, it should probably be deep copied into the server context, which fixes the crash.
This commit is contained in:
parent
1e60f88786
commit
cc931a2319
@ -286,7 +286,9 @@ func startClientListeners(cfg *Config) (sctxs map[string]*serveCtx, err error) {
|
||||
plog.Info("stopping listening for client requests on ", u.Host)
|
||||
}
|
||||
}()
|
||||
sctx.userHandlers = cfg.UserHandlers
|
||||
for k := range cfg.UserHandlers {
|
||||
sctx.userHandlers[k] = cfg.UserHandlers[k]
|
||||
}
|
||||
if cfg.EnablePprof {
|
||||
sctx.registerPprof()
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ type serveCtx struct {
|
||||
|
||||
func newServeCtx() *serveCtx {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
return &serveCtx{ctx: ctx, cancel: cancel}
|
||||
return &serveCtx{ctx: ctx, cancel: cancel, userHandlers: make(map[string]http.Handler)}
|
||||
}
|
||||
|
||||
// serve accepts incoming connections on the listener l,
|
||||
|
Loading…
x
Reference in New Issue
Block a user