-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OUT-OF-PROCESS] Move the Plugin, as a whole out-of-process. (#1647)
* [OUT-OF-PROCESS] Move the Plugin, as a whole out-of-process. On request of Sky Labs Aalborg, we are looking at possibilities to run any plugin, also plugins not coded for out of process, out-of-process to make sure that memory corruption created by such is plugin is only in its own process space and nolonger in the Thunder (WPEFramework) process space. Focus for this feature are mainly plugins created in the RDKService that are not yet prepared to run out of process but are only exposing a JSONRPC to the outside world. The idea is to pass a root config object on plugin level, not on configuration level. If such a root config object is set on plugin level (keyword also "root"), the Framework will start/load the plugin out of process in the ThunderPlugin application process space. The request made (through the regular code) is to return a IPlugin (one of the perls of working interface based all along ;-) ) Now if we retrieve the IPlugin from the module loaded in the ThunderPlugin process space, Thunder framework will continue with this IPlugin as if it where created locally and thus the IDispatcher (For JSONRPC dispatching) are extracted from the IPlugin for handling the JSONRPC over COMRPC (feature available as of R4.4). The Initialize is now also being forwarded through the IPlugin to the instance that is running in the ThunderPlugin process (out-of-process hosting). This means that Initialization of the plugin is only done in the ThunderPlugin process and nolonger in the Thunder (WPEFramework) process so this might lead to unexpected situations. To be found during testing :-) Another point of attention/testing is the feedback of JSONRPC events. More commits might follow to get that properly working. * [OUT-OF-PROCESS] Tested it succefully, more testing needed.. Issues: IDispatcher needs to be intialized and deinitialized, added the ILocalDispatcher methods to the IDispatcher, so the JSONRPC class can also be intialized (Attach) and deinitialized (detach) in the other process space. Crash due to a full Deactivate in case an Activate fails and the new behaviour (Deinitialize called after any faiing Initialize) was assuming JSONRPC stuff was set, which was not :-) Now aonly call Deinitialize in stead of a full Deactivate. Decoupled notification of the channels that are opened and closed. As the closing of the channel was detected by the ResourceMonitor thread, this thread is used to also iterate over the subscribers for notifiation of channel opening and closing. As JSONRPC classes are one of the interested parties to this event, the event now had to travel across a COMRPC boundary, in case the JSONRPC is running out-of-process. A COMRPC call is a no go on the ResourceMonitor thread since that will deadlock ;-) The registration from the IConnectionServer::INotification for the out-of-process plugin was triggered by the Attach of the IDispatcher, however since this registration actively pushes all current open channels to the subscriber we ended up in a deadlock: COMRPC classical deadlock: Thunder -> (IDispatcher::Attach) ThunderPlugin --+ | +------- IShell::Register(sink) <---------------+ | +------> INotification::Open(id) [Oops, in and outbound on COMRPC are already in progress!!!!] Solved by pushing the sink back on the Attach (and later Detach for symetry) and have Thunder Register this sink on behalf of the ouot of process plugin ! Tested sofar calling JSONRPC method on the out-of-process plugin (JSONRPCPlugin in examples of ThunderNanoServices, which worked flawless and did receive already notification that are send by default to the system (inbound events) More testing needs to be done! * Update CMakeLists.txt Seems we need an additional search path for this to work. * Update after review Addressing review remarks of @MFransen69 * Update PluginServer.h Oops collateral damage of the search :-) * Update PluginServer.h * Update CMakeLists.txt Oops * Update PluginServer.h * Update IDispatcher.h --------- Co-authored-by: MFransen69 <[email protected]>
- Loading branch information
1 parent
cb226b3
commit a53cd99
Showing
6 changed files
with
107 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters