Make sockets non-blocking

Andreas Ericsson ae at op5.se
Thu May 6 11:21:36 CEST 2010


On 05/06/2010 12:32 AM, Stephen Gran wrote:
> On Wed, May 05, 2010 at 10:54:48PM +0200, Andreas Ericsson said:
>> On 05/05/2010 03:13 PM, Stephen Gran wrote:
>>> On Sat, May 01, 2010 at 05:03:59PM +0100, Stephen Gran said:
> 
> Yes, scrapping the entire thing and redoing it did occur to me, but I
> thought it might not be the best "hello world" patch on the project
> mailing list :)
> 
> I wasn't too worried about dealing with message queueing, as NDO already
> does that part fairly well (as I'm sure you're aware).

Actually, I'm not. When we started looking at NDOUtils it wasn't very
efficient. Diligent effort has been spent to make it decent, but its
database schema and the fact that it maintains log-entries in a flat
format in a database makes it rather unusable for us. Hence, we decided
to make Merlin database-aware and use that instead. I neither maintain
nor use NDOUtils myself, but I review patches for it whenever I come
across them.

>  I think that
> short term, the simplest logic may be to scrap the while loop altogether
> and just mark the message as failed if you get a partial write.  That
> way the recipient can ditch it without worrying about reassembling
> partial messages, and NDO can deal with it with it's usual retry logic.
> 

Sounds sensible. It should probably re-try immediately on EINTR or
EAGAIN though.

> 
>>> Arguably my choices of 10 loops for termination in write() and 15
>>> seconds for connect() are not right for everyone.  They could be moved
>>> to configuration options, or they could be taken from existing options,
>>> or something.  At this point, it Works For Me(TM), which is good enough
>>> at this point.  If people have any specific objections, I would of course
>>> be happy to tidy it up for them.
>>
>> The connection stuff is totally bearable, but you could easily reduce it
>> to 2 seconds and still have it Work For You without the massive amounts
>> of latency it would mean for people who have forgotten to start the
>> remote end.
> 
> Agreed, but again, see above.  That I felt this way while writing it
> doesn't mean you have to take it as is, of course.  I'd be perfectly
> happy if you wanted the bulk of the patch but thought an 11ms timeout
> was better (although I'd be slightly worried about your sanity :) ).
> 

I'm not the one who'll be applying this patch. NDOUtils unfortunately
stands without a maintainer at the moment (though I guess Ethan has
write access to the repository), so I'm not sure who will take care of
it.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------




More information about the Developers mailing list