I'm going to commit. ok or commet are still welcome.
On Tue, 18 Sep 2012 22:27:19 +0200
Alexander Bluhm <[email protected]> wrote:
> On Fri, Sep 07, 2012 at 01:43:29PM +0900, UMEZAWA Takeshi wrote:
>> I have added send(2) MSG_DONTWAIT support, which enables us to choose
>> nonblocking or blocking for each send(2) call.
>
> I think this diff is OK.
>
> Does anyone know why SS_NBIO and MSG_DONTWAIT are not used identically
> in sosend() and soreceive()? Especially locking the socket buffer
> sblock() with SS_NBIO is different in sosend() and soreceive().
>
> Should't SS_NBIO and MSG_DONTWAIT be evaluated consistently everywhere?
I looked into sosend()/soreceive() for a hour, but it's still mystery
for me..
But I think the diff itself will not hurt anything.
>> diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2
>> index d58588f..b3b8d93 100644
>> --- a/lib/libc/sys/send.2
>> +++ b/lib/libc/sys/send.2
>> @@ -103,6 +103,8 @@ bypass routing, use direct interface
>> .It Dv MSG_NOSIGNAL
>> don't send
>> .Dv SIGPIPE
>> +.It Dv MSG_DONTWAIT
>> +don't block
>> .El
>> .Pp
>> The flag
>> diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
>> index 653de7d..10ef153 100644
>> --- a/sys/kern/uipc_socket.c
>> +++ b/sys/kern/uipc_socket.c
>> @@ -451,7 +451,7 @@ restart:
>> snderr(EMSGSIZE);
>> if (space < resid + clen &&
>> (atomic || space < so->so_snd.sb_lowat || space < clen)) {
>> - if (so->so_state & SS_NBIO)
>> + if ((so->so_state & SS_NBIO) || (flags & MSG_DONTWAIT))
>> snderr(EWOULDBLOCK);
>> sbunlock(&so->so_snd);
>> error = sbwait(&so->so_snd);