Hi,
i have to applications that are connect via IPC.
The client uses a thread which calls server_ConnectService
and then a function like server_dowork(callbackFunc)
.
The problem is that the callbackFunc
doesn’t get called. If I move the server_dowork(callbackFunc)
outside of the thread, everything works as expected and callbackFunc
is called after work is done.
Why does a callback not work in a thread?
What am I missing here?
jyijyi
October 9, 2021, 1:13am
2
Does this application work for server to call the callback function in client?
As I said: it only does if the callback is called outside a thread.
I had a look at the IPC_step4, but this seems to a lot of code that I don’t want to implement, since I only need a simple callback.
So the question remains: why is the callback not working in the thread?
jyijyi
October 11, 2021, 3:18pm
4
I don’t see problem with legato 20.04 on WP76.
IPC_step4_thread.rar (3.6 KB)
I can see that this is working, however as I said, I want to use simple callbacks and not events since events add a lot of code that I don’t want.
Please see my attached sample app that clearly shows that callbacks are not working if a thread is used.callbackTest.zip (2.8 KB)
jyijyi
October 11, 2021, 9:37pm
6
Better use event api() as it is proven to be working
I think the way you are using is not recommended.
Here says circular dependency is not recommended to avoid deadlocks:
Hi,
By default, each app runs in its own sandbox. When an app is constructed, all the IPC services it needs are declared. At runtime, the Supervisor and the Service Directory enforce that only those approved IPC services are accessed by the app. Approval is specified through “bindings”.
Binding is between Client and Server. CLient -Server can be 2 applications or 2 components in application which are 2 different process. This dictates the need for bindings.
Check this link (Application Defini…