Currently we set up a cookie and upon failure not call UdevWait(). This
does not cleanup the cookie and associated semaphore and system will
soon max out on total number of semaphores.
To avoid this, call UdevWait() even in failure path which in turn will
cleanup associated semaphore.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Vincent Batts <vbatts@redhat.com>
| ... | ... |
@@ -373,13 +373,12 @@ func CreatePool(poolName string, dataFile, metadataFile *os.File, poolBlockSize |
| 373 | 373 |
if err := task.SetCookie(&cookie, 0); err != nil {
|
| 374 | 374 |
return fmt.Errorf("Can't set cookie %s", err)
|
| 375 | 375 |
} |
| 376 |
+ defer UdevWait(cookie) |
|
| 376 | 377 |
|
| 377 | 378 |
if err := task.Run(); err != nil {
|
| 378 | 379 |
return fmt.Errorf("Error running DeviceCreate (CreatePool) %s", err)
|
| 379 | 380 |
} |
| 380 | 381 |
|
| 381 |
- UdevWait(cookie) |
|
| 382 |
- |
|
| 383 | 382 |
return nil |
| 384 | 383 |
} |
| 385 | 384 |
|
| ... | ... |
@@ -516,13 +515,12 @@ func ResumeDevice(name string) error {
|
| 516 | 516 |
if err := task.SetCookie(&cookie, 0); err != nil {
|
| 517 | 517 |
return fmt.Errorf("Can't set cookie %s", err)
|
| 518 | 518 |
} |
| 519 |
+ defer UdevWait(cookie) |
|
| 519 | 520 |
|
| 520 | 521 |
if err := task.Run(); err != nil {
|
| 521 | 522 |
return fmt.Errorf("Error running DeviceResume %s", err)
|
| 522 | 523 |
} |
| 523 | 524 |
|
| 524 |
- UdevWait(cookie) |
|
| 525 |
- |
|
| 526 | 525 |
return nil |
| 527 | 526 |
} |
| 528 | 527 |
|
| ... | ... |
@@ -596,12 +594,12 @@ func ActivateDevice(poolName string, name string, deviceId int, size uint64) err |
| 596 | 596 |
return fmt.Errorf("Can't set cookie %s", err)
|
| 597 | 597 |
} |
| 598 | 598 |
|
| 599 |
+ defer UdevWait(cookie) |
|
| 600 |
+ |
|
| 599 | 601 |
if err := task.Run(); err != nil {
|
| 600 | 602 |
return fmt.Errorf("Error running DeviceCreate (ActivateDevice) %s", err)
|
| 601 | 603 |
} |
| 602 | 604 |
|
| 603 |
- UdevWait(cookie) |
|
| 604 |
- |
|
| 605 | 605 |
return nil |
| 606 | 606 |
} |
| 607 | 607 |
|