summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Peter Hurley 2010-10-27 09:29:48 -0400
committerGravatar Stefan Richter 2012-02-05 11:18:40 +0100
commitc6569f39f17af1b05a8a9806d794343a65a0f267 (patch)
tree3084a21289d52d675823d43cb329caf36a60d4ab /src
parentReset device fd upon error condition in handle_inotify() (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/fw.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/fw.c b/src/fw.c
index 2d8a292..558767c 100644
--- a/src/fw.c
+++ b/src/fw.c
@@ -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;
h='13' height='13' alt='Gravatar' /> dmaas 1-1/+3 2003-03-26add raw1394_new_handle_on_port() convenience functionGravatar dmaas 2-1/+41 2003-02-22Updates for new rawiso ioctl interface.Gravatar bencollins 3-37/+125 2003-01-15add iso_xmit_sync() and iso_xmit_write(); clean up iso handling a bitGravatar dmaas 5-39/+161 2003-01-15implement tag matching for rawiso receptionGravatar dmaas 3-4/+12 2003-01-06back out previous commit - don't drop the legacy API just yetGravatar dmaas 6-173/+130 2003-01-05emulate legacy ISO reception API on top of new rawiso APIGravatar dmaas 7-131/+174 2002-12-24update iso API for multi-channel reception and new packet buffer layoutGravatar dmaas 4-123/+236 2002-12-20oops, irq_interval needs to be signedGravatar anonymous 1-1/+1 2002-12-20dmaas - renamed exported arm definitions into the raw1394_ namespace; brought...Gravatar anonymous 3-124/+48 2002-12-16rawiso updates:Gravatar dmaas 3-18/+25 2002-11-18fix cplusplus extern C blockGravatar ddennedy 1-4/+4 2002-11-18merged rawiso branchGravatar ddennedy 7-6/+488