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 committed 2017-11-14 12:17:41 +01:00
1 parent ebb574136b
commit d52254b4ec
2 files changed
+12 -6

No files matched your search

+8 -4
View File
@@ -43,11 +43,15 @@ struct js_event {
*/ */
static void joystick_cb(uev_t *w, void *arg, int events) static void joystick_cb(uev_t *w, void *arg, int events)
{ {
if (UEV_ERROR == events) if (UEV_ERROR == events) {
errx(EBADF, "Unrecoverable error, exiting"); warnx("Spurious problem with the joystick watcher, restarting.");
uev_io_start(w);
}
if (read(w->fd, &e, sizeof(e)) < 0) if (read(w->fd, &e, sizeof(e)) < 0) {
errx(errno, "Failed reading joystick event"); warn("Failed reading joystick event");
return;
}
switch (e.type) { switch (e.type) {
case 1: case 1:
+4 -2
View File
@@ -24,8 +24,10 @@ void process_stdin(uev_t *w, void *arg, int events)
char buf[256]; char buf[256];
int len; int len;
if (UEV_ERROR == events) if (UEV_ERROR == events) {
errx(EBADF, "Unrecoverable error, exiting"); warnx("Spurious problem with the stdin watcher, restarting.");
uev_io_start(w);
}
len = read(w->fd, buf, sizeof(buf)); len = read(w->fd, buf, sizeof(buf));
if (len == -1) { if (len == -1) {