diff options
author | Peter Hurley <phurley@charter.net> | 2010-10-27 09:29:48 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2012-02-05 11:18:40 +0100 |
commit | c6569f39f17af1b05a8a9806d794343a65a0f267 (patch) | |
tree | 3084a21289d52d675823d43cb329caf36a60d4ab | |
parent | ea4acf08bc71872215be84deabfb42b9133660ab (diff) | |
download | libraw1394-c6569f39f17af1b05a8a9806d794343a65a0f267.tar.gz |
Process multiple inotify events
If multiple inotify events are presented, process *all* of them.
This can happen when several device adds are pushed simultaneously.
handle_inotify() was refactored.
Signed-off-by: Peter Hurley <phurley@charter.net>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | src/fw.c | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -360,21 +360,16 @@ handle_device_event(raw1394handle_t handle, } static int -handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, - __uint32_t events) +process_inotify_event(fw_handle_t fwhandle, struct inotify_event *event) { - fw_handle_t fwhandle = handle->mode.fw; - struct inotify_event *event; char filename[32]; struct fw_cdev_get_info info; struct fw_cdev_event_bus_reset reset; struct epoll_event ep; - int i, len, fd, phy_id, fname_str_sz; + int i, fd, phy_id, fname_str_sz; - event = (struct inotify_event *) fwhandle->buffer; - len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); if (!(event->mask & IN_CREATE)) - return -1; + return 0; if (!is_fw_device_name(event->name)) return 0; snprintf(filename, sizeof filename, FW_DEVICE_DIR "/%s", event->name); @@ -433,6 +428,30 @@ handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, return 0; } +static int +handle_inotify(raw1394handle_t handle, struct epoll_closure *ec, + __uint32_t events) +{ + fw_handle_t fwhandle = handle->mode.fw; + struct inotify_event *event; + int len; + int retval = 0; + + event = (struct inotify_event *) fwhandle->buffer; + len = read(fwhandle->inotify_fd, event, BUFFER_SIZE); + + while (len >= sizeof(struct inotify_event)) { + retval = process_inotify_event(fwhandle, event); + if (retval == -1) + break; + len -= sizeof(struct inotify_event) + event->len; + event = (struct inotify_event *) ((char *)event + + (sizeof(struct inotify_event) + event->len)); + } + + return retval; +} + int fw_loop_iterate(raw1394handle_t handle) { int i, count, retval = 0; |