Skip to content

Commit

Permalink
Merge pull request #2453 from actiontech/fix_plugin_pidfile_nil_pointer
Browse files Browse the repository at this point in the history
fix: plugin pid file walk nil pointer
  • Loading branch information
ColdWaterLW committed Jun 7, 2024
2 parents 0c424f8 + ff8209f commit 6db901a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sqle/driver/plugin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (pm *pluginManager) Start(pluginDir string, pluginConfigList []config.Plugi
// kill plugins process residual and remove pidfile
var wg sync.WaitGroup
dir := GetPluginPidDirPath(pluginDir)
if err := os.MkdirAll(dir, 0644); err != nil {
return err
}
if err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() && strings.HasSuffix(info.Name(), ".pid") {
wg.Add(1)
Expand Down Expand Up @@ -366,11 +369,8 @@ func GetPluginPidFilePath(pluginDir string, pluginName string) string {
}

func WritePidFile(pidFilePath string, pid int64) error {
_, err := os.Stat(pidFilePath)
if os.IsNotExist(err) {
if err := os.MkdirAll(filepath.Dir(pidFilePath), 0644); err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(pidFilePath), 0644); err != nil {
return err
}
file, err := os.OpenFile(pidFilePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
Expand Down

0 comments on commit 6db901a

Please sign in to comment.