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?

bluhm

> 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);

Reply via email to