[Spread-users] Spread and select

Hua Zhong hzhong at gmail.com
Fri Apr 7 22:29:36 EDT 2006


Matthew,

Thanks for the reply , see inline.

> Hua Zhong wrote:
> >
> > It doesn't seem to be very difficult to do considering the mbox is 
> > actually a socket handle. I could certainly do a select on 
> it myself, and hack SP_receive to do a non-blocking mode 
> read. But I'd like to understand why it's not provided as a 
> standard API.
> > Thanks.
> > 
> > Please let me know your opinion, thanks.
> 
> There's an example of using select() with the mbox fd in the 
> event system that is provided with Spread.  You don't have to 
> hack SP_receive at all (that's the whole point of using 
> select()! ).  See the E_handle_events function of events.c

Good, but there are a couple of issues:
1. it's not documented, thus making me wonder if it's officially supported feature. In fact, there is not even a SP_mailbox_to_fd
kind of helper. How could one assume mailbox == fd? It's implementation details that could change anytime, and nothing to depend on.
2. there is still not a non-blocking version SP_receive. As I explained earlier, it's not very nice to programers.

I just checked the spread code (v3.17.3) and find the following in sp.c:

		while(((ret = recv( mbox, &scat_mess->elements[scat_index].buf[byte_index], to_read, 0 )) == -1 )
                      		&& ((sock_errno == EINTR) || (sock_errno == EAGAIN) || (sock_errno == EWOULDBLOCK)) )
 
This is very weird. If it's a blocking socket, it should never return EGAIN. If it's a non-blocking socket, the above effectily will
spin forever until there is data.

Anyway, I think it would be a great improvement if non-blocking API could be provided.

Hua

> It's really simple to use select() on your own.  I don't 
> really see how providing a wrapper for that would provide 
> much benefit.
> 
> Matt
> 





More information about the Spread-users mailing list