[Spice-devel] [spice-server v3 3/6] net: Introduce red_socket_set_non_blocking() helper
Christophe Fergeau
cfergeau at redhat.com
Fri Mar 31 09:15:46 UTC 2017
On Thu, Mar 30, 2017 at 12:27:06PM -0500, Jeremy White wrote:
> Hi,
>
> On 03/16/2017 10:02 AM, Christophe Fergeau wrote:
> > This allows to move some low-level code out of reds.c
> >
> > Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> > ---
> > server/net-utils.c | 24 ++++++++++++++++++++++++
> > server/net-utils.h | 1 +
> > server/reds.c | 13 ++-----------
> > 3 files changed, 27 insertions(+), 11 deletions(-)
> >
> > diff --git a/server/net-utils.c b/server/net-utils.c
> > index 10f447b..0e533f5 100644
> > --- a/server/net-utils.c
> > +++ b/server/net-utils.c
> > @@ -52,3 +52,27 @@ bool red_socket_set_no_delay(int fd, bool no_delay)
> >
> > return true;
> > }
> > +
> > +/**
> > + * red_socket_set_non_blocking:
> > + * @fd: a socket file descriptor
> > + * @non_blocking: whether to enable O_NONBLOCK on @fd
> > + *
> > + * Returns: #true if the operation succeeded, #false otherwise.
> > + */
> > +bool red_socket_set_non_blocking(int fd, bool non_blocking)
> > +{
> > + int flags;
> > +
> > + if ((flags = fcntl(fd, F_GETFL)) == -1) {
> > + spice_warning("fnctl(F_GETFL) failed, %s", strerror(errno));
> > + return false;
> > + }
> > +
> > + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) {
> > + spice_warning("fnctl(F_SETFL) failed, %s", strerror(errno));
> > + return false;
> > + }
> > +
> > + return true;
> > +}
>
> Doesn't this ignore the non_blocking parameter?
Oops, thanks a lot for catching this! Too hasty copy and paste! v4
incoming :)
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170331/241d7b6e/attachment.sig>
More information about the Spice-devel
mailing list