C# Subscriber.lookup_datareader() blocks forever

3 posts / 0 new
Last post
Offline
Last seen: 5 years 9 months ago
Joined: 06/25/2013
Posts: 5
C# Subscriber.lookup_datareader() blocks forever

Hello,

I'm having a problem in CSharp where sometimes (seems to be random) my call to lookup_datareader("DCPSParticipant") never returns. Here is my (simplified) code:

DDS.DomainParticipantQos qos = DDS.DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT;

qos.resource_limits.type_code_max_serialized_length = 1024 * 32;

DDS.DomainParticipant participant = DDS.DomainParticipantFactory.get_instance().create_participant( DomainId, qos, null, DDS.StatusMask.STATUS_MASK_NONE);

DDS.Subscriber builtInSubscriber = participant.get_builtin_subscriber();

DDS.DataReader participantReader = m_builtInSubscriber.lookup_datareader("DCPSParticipant");

if (participantReader != null)

    participantReader.set_listener(new PublisherListener(), DDS.StatusMask.STATUS_MASK_ALL);

 Any ideas what would cause the lookup_datareader() method to not return? My code is basically registering all participants on the domain within the PublisherListener.

Thanks in advance.

Offline
Last seen: 6 years 1 month ago
Joined: 06/24/2013
Posts: 8

Greetings:

I looked into this a bit, and can't find anything that might explain what you are seeing. The only possible reason I could see is that the documentation states that the lookup_datareader operation is not thread safe. (Shouldn't be called while the reader is being created). That being said, the create participant operation is synchronous - i.e., it should not return until all the built in readers and writers have been created, and with that being the case, the code snippet that you show should work without problems (I'm assuming that participantReader and publicationReader are actually the same variable).

So, at this point, all I can ask if you might have other threads that could possibly be interfering? I'm sorry to not have more suggestions.

Regards,

Kevin

Offline
Last seen: 5 years 9 months ago
Joined: 06/25/2013
Posts: 5

Thanks for your response. I had suspected a concurrency issue as my application is multi-threaded, and also the intermittent nature of the problem. I added a lock around the block of code that calls lookup_datareader() and have not seen the issue since.