<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>RE: [PATCH] libsdp: enable fallback to TCP for nonblocking sockets</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><FONT SIZE=2>Yossi Hi,<BR>
<BR>
I'm on vacation till Monday.<BR>
I'll check when can we have the full fix - and if it is not in the near future<BR>
we'll put your patch till the full fix be prepared.<BR>
<BR>
- Amir<BR>
<BR>
-----Original Message-----<BR>
From: Yossi Etigin [<A HREF="mailto:yossi.openib@gmail.com">mailto:yossi.openib@gmail.com</A>]<BR>
Sent: Mon 8/25/2008 6:18 PM<BR>
To: Amir Vadai<BR>
Cc: general list; Oren Duer; Olga Shern<BR>
Subject: Re: [PATCH] libsdp: enable fallback to TCP for nonblocking sockets<BR>
<BR>
Hi Amir,<BR>
<BR>
The single case in which we block connect() here (and only on SDP, which<BR>
is rather fast) is the case that is currenlty not supported anyway. It can<BR>
also be configurable.<BR>
Anyway, we have a client which uses non-blocking sockets and really needs<BR>
that feature. How about putting this to OFED now and writing something better<BR>
later on?<BR>
<BR>
--Yossi<BR>
<BR>
<BR>
Amir Vadai wrote:<BR>
> See below<BR>
><BR>
> On Thu, 2008-08-21 at 19:49 +0300, Yossi Etigin wrote:<BR>
>> Hi Amir,<BR>
>><BR>
>> What you suggesting is to replace almost all socket functions, and I<BR>
>> don't think that this is good either.<BR>
> I agree - but to break the non-blocking semantics is worse.<BR>
><BR>
>> It would be write(), send(), recv(), sendto(), recvfrom(), sendmsg(),<BR>
>> recvmsg(), and also need to change select() (to not return when<BR>
>> fallback<BR>
>> happens if SDP fails), and maybe also poll(). libsdp tries to avoid<BR>
>> the fast path.<BR>
> I don't see another option. We could have a #ifdef to enable the user<BR>
> to choose - non blocking support or cleaner fast-path.<BR>
>> Besides, how do we know when to do fallback - can we safely assume<BR>
>> that if some socket operation fails, then it happened because<BR>
>> connect() failed?<BR>
>>From a brief look at connect man page, they say we should use select for<BR>
> writing on the socket. after select indicates writability, use<BR>
> getsockopt to determine whether connect() completed successfully or not.<BR>
>> Anyway, if I understand correctly, you suggest something like:<BR>
>><BR>
>> int connect(fd, ...)<BR>
>> {<BR>
>> ...<BR>
>> set_state(fd, SDP)<BR>
>> ...<BR>
>> }<BR>
>><BR>
>><BR>
>> int read(int fd, ...)<BR>
>> {<BR>
>> int res = socket_funcs.read(shadow_fd(fd), ...);<BR>
>> if (res < 0 && errno != EAGAIN && sock_state(fd) == SDP) {<BR>
>> sock_state = TCP;<BR>
>> sockt_funs.connect(fd,...);<BR>
>> close(shadow_fd(fd));<BR>
>> errno = EAGAIN;<BR>
>> }<BR>
>> return res;<BR>
>> }<BR>
>><BR>
>><BR>
> ... again, I don't like it too - but I don't think we should block<BR>
> connect when the user asks not to.<BR>
> - Amir.<BR>
>> --Yossi<BR>
>><BR>
>> Amir Vadai wrote:<BR>
>>> Yossi Hi,<BR>
>>><BR>
>>> I think that breaking the semantic of non blocking socket is a bad<BR>
>> idea.<BR>
>>> There is a solution that won't break this semantics:<BR>
>>><BR>
>>> 1. User app calls connect().<BR>
>>> - libsdp try to connect through sdp.<BR>
>>> 2. User app try another operation on the socket (e.g read/write)<BR>
>>> - if sdp connection established successfully - great<BR>
>>> - if sdp still not established - return -EAGAIN. This is the<BR>
>>> same behaviour as if the tcp connection wasn't connected yet.<BR>
>>> - if sdp timedout - return -EAGAIN and initiate TCP connect.<BR>
>>> - if tcp connection established - use it<BR>
>>> - if tcp connection timedout - return error.<BR>
>>><BR>
>>> Maybe we could optimize it and initiate a tcp connection in parallel<BR>
>>> with the sdp connection and use it only when the sdp connect is<BR>
>>> timedout.<BR>
>>><BR>
>>> I will add only the second patch (the debug print fix).<BR>
>>><BR>
>>> - Amir<BR>
>>><BR>
>>><BR>
>><BR>
>><BR>
><BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>