Make sure to restart the I/O watcher on UEV_ERROR

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-11-14 12:17:41 +01:00
parent ebb574136b
commit d52254b4ec
2 changed files with 12 additions and 6 deletions
+8 -4
View File
@@ -43,11 +43,15 @@ struct js_event {
*/
static void joystick_cb(uev_t *w, void *arg, int events)
{
if (UEV_ERROR == events)
errx(EBADF, "Unrecoverable error, exiting");
if (UEV_ERROR == events) {
warnx("Spurious problem with the joystick watcher, restarting.");
uev_io_start(w);
}
if (read(w->fd, &e, sizeof(e)) < 0)
errx(errno, "Failed reading joystick event");
if (read(w->fd, &e, sizeof(e)) < 0) {
warn("Failed reading joystick event");
return;
}
switch (e.type) {
case 1:
+4 -2
View File
@@ -24,8 +24,10 @@ void process_stdin(uev_t *w, void *arg, int events)
char buf[256];
int len;
if (UEV_ERROR == events)
errx(EBADF, "Unrecoverable error, exiting");
if (UEV_ERROR == events) {
warnx("Spurious problem with the stdin watcher, restarting.");
uev_io_start(w);
}
len = read(w->fd, buf, sizeof(buf));
if (len == -1) {