| 702 | static GlobalPtr<DelayedDelete> delayedDelete; |
| 703 | |
| 704 | int ConfiguredPlugin::release() |
| 705 | { |
| 706 | int x = --refCounter; |
| 707 | |
| 708 | #ifdef DEBUG_PLUGINS |
| 709 | fprintf(stderr, "ConfiguredPlugin::release %s %d\n", plugName.c_str(), x); |
| 710 | #endif |
| 711 | |
| 712 | if (x == 0) |
| 713 | { |
| 714 | { // plugins->mutex scope |
| 715 | MutexLockGuard g(plugins->mutex, FB_FUNCTION); |
| 716 | if (refCounter != 0) |
| 717 | return 1; |
| 718 | |
| 719 | if (Why::timerThreadStopped() && !processingDelayedDelete && delayedDelete) |
| 720 | { |
| 721 | // delay delete |
| 722 | addRef(); |
| 723 | delayedDelete->push(this); |
| 724 | |
| 725 | return 1; |
| 726 | } |
| 727 | |
| 728 | destroy(); |
| 729 | } |
| 730 | |
| 731 | // Must run out of mutex scope to avoid deadlock with PluginManager::threadDetach() |
| 732 | // called when module is unloaded by dtor |
| 733 | delete this; |
| 734 | return 0; |
| 735 | } |
| 736 | |
| 737 | return 1; |
| 738 | } |
| 739 | |
| 740 | void ConfiguredPlugin::processDelayedDelete() |
| 741 | { |
no test coverage detected