Branch: Tag:

2015-10-07

2015-10-07 09:30:24 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Inotify: Don't throw errors in rm_watch() on invalid watch descriptor.

The watch descriptor may already have been implicitly invalidated,
and the corresponding IN_IGNORED not received and handled yet.

As the end result of calling rm_watch() in either case is that the
watch descriptor is invalid, it doesn't make sense to throw an error.

237:       err = inotify_rm_watch(THIS->fd, wd);    -  if (err == 0) { +  if (!err || (errno == EINVAL)) { +  /* NB: EINVAL typically means that the watch descriptor is +  * invalid, and is often triggered by the descriptor +  * having been automatically removed. +  */    return;    }    -  if (errno == EINVAL) { -  Pike_error("Wrong argument to rm_watch().\n"); -  } else if (errno == EBADF) { +  if (errno == EBADF) {    Pike_error("Oups. I feel funny inside.\n");    } -  +  Pike_error("Unexpected error: %d.\n", errno);    }       INIT {