[ofa-general] ***SPAM*** Re: [PATCH] libsdp: enable fallback to TCP for nonblocking sockets

Yossi Etigin yossi.openib at gmail.com
Thu Aug 21 09:49:04 PDT 2008


Hi Amir,

What you suggesting is to replace almost all socket functions, and I
don't think that this is good either.
It would be write(), send(), recv(), sendto(), recvfrom(), sendmsg(),
recvmsg(), and also need to change select() (to not return when fallback
happens if SDP fails), and maybe also poll(). libsdp tries to avoid
the fast path.

Besides, how do we know when to do fallback - can we safely assume
that if some socket operation fails, then it happened because
connect() failed?


Anyway, if I understand correctly, you suggest something like:

int connect(fd, ...)
{
	...
	set_state(fd, SDP)
	...
}


int read(int fd, ...)
{
	int res = socket_funcs.read(shadow_fd(fd), ...);
	if (res < 0 && errno != EAGAIN && sock_state(fd) == SDP) {
		sock_state = TCP;
		sockt_funs.connect(fd,...);
		close(shadow_fd(fd));
		errno = EAGAIN;
	}
	return res;
}




--Yossi

Amir Vadai wrote:
> Yossi Hi,
> 
> I think that breaking the semantic of non blocking socket is a bad idea.
> 
> There is a solution that won't break this semantics:
> 
> 1. User app calls connect().
> 	- libsdp try to connect through sdp.
> 2. User app try another operation on the socket (e.g read/write)
> 	- if sdp connection established successfully - great
> 	- if sdp still not established - return -EAGAIN. This is the
> same behaviour as if the tcp connection wasn't connected yet.
> 	- if sdp timedout - return -EAGAIN and initiate TCP connect.
> 	- if tcp connection established - use it
> 	- if tcp connection timedout - return error.
> 
> Maybe we could optimize it and initiate a tcp connection in parallel
> with the sdp connection and use it only when the sdp connect is
> timedout.
> 
> I will add only the second patch (the debug print fix).
> 
> - Amir
>  
> 




More information about the general mailing list