mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(master):fix the problem of gosec
Signed-off-by: shuqiang-zheng <zhengshuqiang@oppo.com>
This commit is contained in:
parent
40ddb416d0
commit
bd13838523
@ -243,15 +243,24 @@ func main() {
|
||||
|
||||
if profPort != "" {
|
||||
go func() {
|
||||
mainMux := http.NewServeMux()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
http.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
mux.Handle("/debug/pprof", http.HandlerFunc(pprof.Index))
|
||||
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
mux.Handle("/debug/", http.HandlerFunc(pprof.Index))
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", profPort), mux)
|
||||
mainHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if strings.HasPrefix(req.URL.Path, "/debug/") {
|
||||
mux.ServeHTTP(w, req)
|
||||
} else {
|
||||
http.DefaultServeMux.ServeHTTP(w, req)
|
||||
}
|
||||
})
|
||||
mainMux.Handle("/", mainHandler)
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", profPort), mainMux)
|
||||
if e != nil {
|
||||
log.LogFlush()
|
||||
err = errors.NewErrorf("cannot listen pprof %v err %v", profPort, err)
|
||||
|
||||
@ -610,7 +610,7 @@ func mount(opt *proto.MountOptions) (fsConn *fuse.Conn, super *cfs.Super, err er
|
||||
if opt.LocallyProf {
|
||||
pprofAddr = "127.0.0.1:" + opt.Profport
|
||||
}
|
||||
|
||||
mainMux := http.NewServeMux()
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/debug/pprof", http.HandlerFunc(pprof.Index))
|
||||
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
@ -618,8 +618,16 @@ func mount(opt *proto.MountOptions) (fsConn *fuse.Conn, super *cfs.Super, err er
|
||||
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
mux.Handle("/debug/", http.HandlerFunc(pprof.Index))
|
||||
mainHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if strings.HasPrefix(req.URL.Path, "/debug/") {
|
||||
mux.ServeHTTP(w, req)
|
||||
} else {
|
||||
http.DefaultServeMux.ServeHTTP(w, req)
|
||||
}
|
||||
})
|
||||
mainMux.Handle("/", mainHandler)
|
||||
|
||||
go waitListenAndServe(statusCh, pprofAddr, mux)
|
||||
go waitListenAndServe(statusCh, pprofAddr, mainMux)
|
||||
if err = <-statusCh; err != nil {
|
||||
daemonize.SignalOutcome(err)
|
||||
return
|
||||
|
||||
13
cmd/cmd.go
13
cmd/cmd.go
@ -288,15 +288,24 @@ func main() {
|
||||
|
||||
if profPort != "" {
|
||||
go func() {
|
||||
mainMux := http.NewServeMux()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
http.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
mux.Handle("/debug/pprof", http.HandlerFunc(pprof.Index))
|
||||
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
mux.Handle("/debug/", http.HandlerFunc(pprof.Index))
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", profPort), mux)
|
||||
mainHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if strings.HasPrefix(req.URL.Path, "/debug/") {
|
||||
mux.ServeHTTP(w, req)
|
||||
} else {
|
||||
http.DefaultServeMux.ServeHTTP(w, req)
|
||||
}
|
||||
})
|
||||
mainMux.Handle("/", mainHandler)
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", profPort), mainMux)
|
||||
if e != nil {
|
||||
log.LogFlush()
|
||||
err = errors.NewErrorf("cannot listen pprof %v err %v", profPort, e)
|
||||
|
||||
@ -22,6 +22,7 @@ import (
|
||||
"net/http/pprof"
|
||||
"path"
|
||||
gopath "path"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -94,15 +95,24 @@ func NewClient(config PreloadConfig) *PreLoadClient {
|
||||
|
||||
if config.ProfPort != "" {
|
||||
go func() {
|
||||
mainMux := http.NewServeMux()
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
http.HandleFunc(log.SetLogLevelPath, log.SetLogLevel)
|
||||
mux.Handle("/debug/pprof", http.HandlerFunc(pprof.Index))
|
||||
mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
|
||||
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
|
||||
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
|
||||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
|
||||
mux.Handle("/debug/", http.HandlerFunc(pprof.Index))
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", config.ProfPort), mux)
|
||||
mainHandler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
if strings.HasPrefix(req.URL.Path, "/debug/") {
|
||||
mux.ServeHTTP(w, req)
|
||||
} else {
|
||||
http.DefaultServeMux.ServeHTTP(w, req)
|
||||
}
|
||||
})
|
||||
mainMux.Handle("/", mainHandler)
|
||||
e := http.ListenAndServe(fmt.Sprintf(":%v", config.ProfPort), mainMux)
|
||||
if e != nil {
|
||||
log.LogWarnf("newClient newEBSClient cannot listen pprof (%v)", config.ProfPort)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user