Overview
Features
Download
Documentation
Community
Add-Ons & Services

Reactor / Connector

Please post support and help requests here.

Reactor / Connector

Postby cdelmas » 05 Jul 2007, 15:17

Hello all,
I don't understand how I can use a SocketReactor with a SocketConnector. According to the pattern Reactor-Connector, a single Connector is able to initiate n service handlers. But actually, once a connector has initiated a service handler, it unregisters itself with the reactor.

I don't understand why running the reactor with no connectors registered (that is, call the run function before registering a connector) fails with "Invalid Argument" exception.

Can anybody throw light on me ?

Thanks in advance.
cdelmas
 
Posts: 46
Joined: 22 Sep 2006, 10:04
Location: France

Re: Reactor / Connector

Postby cdelmas » 10 Aug 2007, 16:23

I've found why this isn't ok. In the SocketReactor: :run function, there is a call to Socket: :select that fails because the inner : :select call returns -1.

readList, writeList and exceptList are all empty lists, so select is called as follows :
Code: Select all

fd_set readl, writel, exceptl;
FD_ZERO(&readl);
FD_ZERO(&writel);
FD_ZERO(&exceptl);
::select(1, &readl, &writel, &exceptl, &tv); // timeout set to 250000 microseconds

That call returns -1.

Then, I ask my question again : is it normal behavior for the reactor to fail if no connector is registered? If the answer is no, I think the Socket::select code may be reviewed to handle this case.

If I am wrong, please tell me why. Thanks for your answers.
cdelmas
 
Posts: 46
Joined: 22 Sep 2006, 10:04
Location: France

Re: Re: Reactor / Connector

Postby alex » 13 Aug 2007, 14:05

> Then, I ask my question again : is it normal behavior for the reactor to fail if no connector is registered? If the answer is no, I think the Socket::select code may be reviewed to handle this case.

It seems that having reactor without connector makes no sense.

I'm not that familiar with the code, but I guess what you are suggesting could be "fixed" by either not calling Socket: :select() if all the containers (read,write,except) are empty or returning from Socket::select() immediately without error if that is the case. This kind of logic, however, could result in high CPU usage without a sleep() call in the loop.

I'm not sure if this logic holds water, so I'll leave the author of the code (I suspect Guenter) to make the final judgment what (if anything) to do about this.

Alex
alex
 
Posts: 1048
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest