take_next_sample stucks

2 posts / 0 new
Last post
Offline
Last seen: 7 years 3 months ago
Joined: 12/26/2016
Posts: 2
take_next_sample stucks

Hello,

In my code I don't always want my system to handle an incoming message just at that moment, so I create signals and that sort of things in the listeners to wake up appropriate mechanisms in the code. And when I handle these messages (I mean taking data from the datareader) I use take_next_sample method. But, unfortunately, after 1 or 2 messages, this method stucks giving no error. When I look at deeply, I saw that take_next_sample method tries to lock some database mutex and waits for the mutex (probably a deadlock or sth.). -- micro 2.4.7

The code itself sometimes work and sometimes don't due to this problem. And when it works, it gets invalid sample info sometimes. (Normally I should not get that much invalid data, I assume)

After searching on the forum I saw that some people did get a less troubled flow with take method but I assume in this case it might not be relevant because I initialize my variables as suggested in the answers of those problems.

What might be the problem? Where should I look? Could it be that when I try to get data from reader and another message comes something goes wrong?  Beyond these, isn't it a problem that should be solved that library functions can stuck somehow?

I cannot share the whole code here due to some reasons :) (Even if I share, probably no one would understand. And I do not think it is necessary, neither.) But for any possibility that anyone thought of, I will try to be clear in response. Any help will be appreciated. Thank you in advance.

Ozer

Offline
Last seen: 7 years 3 months ago
Joined: 12/26/2016
Posts: 2

I found the problem. Somewhere in the forum I saw that inside of listener on_data_available functions are exclusion zones, so waiting there is bad for simply anything. In my code I had condition variable signal with a mutex lock (to use condition signals in a more proper way); and that lock causes problem because it makes listener wait. So the rest is unpredictable results... :)

I strongly think that you should increase documentation on connext micro. In this case 'best practices' section helped me luckily.