[Spice-devel] [PATCH xf86-video-qxl 3/4] Reopen the uinput socket after a close.
Jeremy White
jwhite at codeweavers.com
Fri Oct 16 14:06:28 PDT 2015
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>>
>> static void spiceqxl_uinput_read_cb(int fd, int event, void
>> *opaque) { @@ -30,14 +31,20 @@ static void
>> spiceqxl_uinput_read_cb(int fd, int event, void *opaque) static
>> int y = -1; static int buttons_state = 0; int button = -1; +
>> qxl_screen_t *qxl = (qxl_screen_t *) opaque;
>>
>> n = read(uinput_fd, (char *)&inp_event + offset,
>> sizeof(inp_event) - offset); - if (n == -1) { - if
>> (errno != EAGAIN && errno != EINTR && errno != EWOULDBLOCK) { -
>> fprintf(stderr, "spice: uinput read failed: %s\n",
>> strerror(errno)); - } + if (n == -1 && +
>> (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
>> return; + + if (n <= 0) { + fprintf(stderr, "spice:
>> uinput read failed: %d-%s\n", n, n == 0 ? "closed" :
>> strerror(errno)); + spiceqxl_uinput_term(qxl); +
>> spiceqxl_uinput_init(qxl); + return; } +
>
> Nit, I think you could keep it like if (n == -1) { if (errno !=
> EAGAIN || ...) { /* reopen uinput socket */ } return; } I think it
> would be slightly more readable. Or did you want to save an
> indentation level ?
mm. I think you overlooked the n == 0 case; that makes your proposal
a bit more convoluted.
I also like the simple connection of the -1/EAGAIN to the return; I
find that to be a more clear expression.
Cheers,
Jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEARECAAYFAlYhZtAACgkQq6U76EE4uyfNOACdFpgX9lQmCijrNxbXdSsi1Ubq
bVgAni/JnnSh+0gwJ/BCFsz5Vw5xcEUx
=ne4Q
-----END PGP SIGNATURE-----
More information about the Spice-devel
mailing list