+ /* Update pollfd array if an entry was added to fd_pairs */
+ pthread_rwlock_rdlock(&fd_pairs_lock);
+ if((inotify_fds + fd_pairs->num_pairs) != num_pollfd) {
+ pollfd = realloc(pollfd,
+ (inotify_fds + fd_pairs->num_pairs) * sizeof(struct pollfd));
+ for(i=num_pollfd-inotify_fds;i<fd_pairs->num_pairs;i++) {
+ pollfd[inotify_fds+i].fd = fd_pairs->pair[i].channel;
+ pollfd[inotify_fds+i].events = POLLIN|POLLPRI;
+ }
+ num_pollfd = fd_pairs->num_pairs + inotify_fds;
+ }
+ pthread_rwlock_unlock(&fd_pairs_lock);
+
+ /* NB: If the fd_pairs structure is updated by another thread from this
+ * point forward, the current thread will wait in the poll without
+ * monitoring the new channel. However, this thread will add the
+ * new channel on next poll (and this should not take too much time
+ * on a loaded system).
+ *
+ * This event is quite unlikely and can only occur if a CPU is
+ * hot-plugged while multple lttd threads are running.
+ */