| 4391 | | |
|---|
| 4392 | | # Since this may take awhile, we perform the remaining operations in a child thread. |
|---|
| 4393 | | my $thread = async { |
|---|
| 4394 | | |
|---|
| 4395 | | # Register a kill signal handler. |
|---|
| 4396 | | # This handler is designed to kill this thread upon overall module |
|---|
| 4397 | | # destruction. This handler should never be used for normal program |
|---|
| 4398 | | # operations, since it will NOT release any locks/semaphores properly. |
|---|
| 4399 | | local $SIG{USR1} = sub { threads->exit(); }; |
|---|
| 4400 | | |
|---|
| 4401 | | $maxThreadSemaphore->down(); |
|---|
| 4402 | | threads->yield(); |
|---|
| 4403 | | |
|---|
| | 4391 | # Perform the snapshot operation... |
|---|
| | 4392 | # XXX: Do this synchronously instead of asynchronously, since we've had problems running |
|---|
| | 4393 | # this code in multi-threaded environments. |
|---|
| | 4394 | # # Since this may take awhile, we perform the remaining operations in a child thread. |
|---|
| | 4395 | # my $thread = async { |
|---|
| | 4396 | # |
|---|
| | 4397 | # # Register a kill signal handler. |
|---|
| | 4398 | # # This handler is designed to kill this thread upon overall module |
|---|
| | 4399 | # # destruction. This handler should never be used for normal program |
|---|
| | 4400 | # # operations, since it will NOT release any locks/semaphores properly. |
|---|
| | 4401 | # local $SIG{USR1} = sub { threads->exit(); }; |
|---|
| | 4402 | # |
|---|
| | 4403 | # $maxThreadSemaphore->down(); |
|---|
| | 4404 | # threads->yield(); |
|---|
| | 4405 | # |
|---|
| 4406 | | |
|---|
| 4407 | | local $SIG{INT} = sub { |
|---|
| 4408 | | my $LOG = get_logger(); |
|---|
| 4409 | | $LOG->warn("Asynchronous snapshot of ($vmDir) interrupted!"); |
|---|
| 4410 | | # Release any acquired locks. |
|---|
| 4411 | | $vmSemaphore->up(); |
|---|
| 4412 | | $maxThreadSemaphore->up(); |
|---|
| 4413 | | threads->exit(); |
|---|
| 4414 | | }; |
|---|
| 4415 | | |
|---|
| 4416 | | # Trap all faults that may occur from these asynchronous operations. |
|---|
| 4417 | | # None of the VmPerl objects are thread-safe, so in order to perform the following |
|---|
| 4418 | | # commands, we must do callbacks to the main thread over SOAP. |
|---|
| 4419 | | # Yes, this is annoying and ugly. |
|---|
| 4420 | | eval { |
|---|
| 4421 | | |
|---|
| | 4408 | # |
|---|
| | 4409 | # local $SIG{INT} = sub { |
|---|
| | 4410 | # my $LOG = get_logger(); |
|---|
| | 4411 | # $LOG->warn("Asynchronous snapshot of ($vmDir) interrupted!"); |
|---|
| | 4412 | # # Release any acquired locks. |
|---|
| | 4413 | # $vmSemaphore->up(); |
|---|
| | 4414 | # $maxThreadSemaphore->up(); |
|---|
| | 4415 | # threads->exit(); |
|---|
| | 4416 | # }; |
|---|
| | 4417 | # |
|---|
| | 4418 | # # Trap all faults that may occur from these asynchronous operations. |
|---|
| | 4419 | # # None of the VmPerl objects are thread-safe, so in order to perform the following |
|---|
| | 4420 | # # commands, we must do callbacks to the main thread over SOAP. |
|---|
| | 4421 | # # Yes, this is annoying and ugly. |
|---|
| | 4422 | # eval { |
|---|
| | 4423 | # |
|---|