deadlock fixed i guess
This commit is contained in:
parent
e19548a0b6
commit
ec9bbe8a6c
1 changed files with 18 additions and 9 deletions
|
@ -438,12 +438,13 @@ func (p *PoolMaster) PackPool(poolID string) (packResult PoolPackResult, err err
|
|||
startTime := time.Now()
|
||||
packResult.PoolID = poolID
|
||||
|
||||
fmt.Printf("Aquiring Lock for PackPool(%s)\n", poolID)
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
defer fmt.Printf("unlock PackPool\n")
|
||||
fmt.Printf("Aquired Lock success for PackPool(%s)\n", poolID)
|
||||
|
||||
/*
|
||||
fmt.Printf("Aquiring Lock for PackPool(%s)\n", poolID)
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
defer fmt.Printf("unlock PackPool\n")
|
||||
fmt.Printf("Aquired Lock success for PackPool(%s)\n", poolID)
|
||||
*/
|
||||
packResult.outputFileName = filepath.Join(p.cachePath, "pool", fmt.Sprintf("%s.tar", poolID))
|
||||
tarFile, err := os.Create(packResult.outputFileName)
|
||||
if err != nil {
|
||||
|
@ -804,7 +805,8 @@ func main() {
|
|||
|
||||
go func() {
|
||||
for {
|
||||
for index, fullPool := range poolMaster.FullPools {
|
||||
var deletedPools []string
|
||||
for _, fullPool := range poolMaster.FullPools {
|
||||
poolMaster.lock.Lock()
|
||||
|
||||
packResult, err := poolMaster.PackPool(fullPool.PoolID)
|
||||
|
@ -820,10 +822,17 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
os.RemoveAll(filepath.Join(poolMaster.cachePath, "pool", fullPool.PoolID))
|
||||
poolMaster.FullPools = removeFromSlice(poolMaster.FullPools, index)
|
||||
|
||||
deletedPools = append(deletedPools, fullPool.PoolID)
|
||||
poolMaster.lock.Unlock()
|
||||
}
|
||||
for _, deletedPoolID := range deletedPools {
|
||||
for index, fullPool := range poolMaster.FullPools {
|
||||
if fullPool.PoolID == deletedPoolID {
|
||||
poolMaster.FullPools = removeFromSlice(poolMaster.FullPools, index)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Add table
Reference in a new issue