|
|
GAM_DEBUG(DEBUG_INFO, "Removing %s from inotify\n", path); | GAM_DEBUG(DEBUG_INFO, "Removing %s from inotify\n", path); |
break; | break; |
case GAMIN_FLOWCONTROLSTART: | case GAMIN_FLOWCONTROLSTART: |
GAM_DEBUG(DEBUG_INFO, "Start flow control for %s\n", path); |
GAM_DEBUG(DEBUG_INFO, "inotify: Start flow control for %s\n", path); |
break; | break; |
case GAMIN_FLOWCONTROLSTOP: | case GAMIN_FLOWCONTROLSTOP: |
GAM_DEBUG(DEBUG_INFO, "Stop flow control for %s\n", path); |
GAM_DEBUG(DEBUG_INFO, "inotify: Stop flow control for %s\n", path); |
break; | break; |
default: | default: |
gam_error(DEBUG_INFO, "Unknown inotify operation %d for %s\n", | gam_error(DEBUG_INFO, "Unknown inotify operation %d for %s\n", |
|
|
} | } |
GAM_DEBUG(DEBUG_INFO, " not found using parent\n"); | GAM_DEBUG(DEBUG_INFO, " not found using parent\n"); |
} | } |
|
#if 0 |
if (data != NULL) { | if (data != NULL) { |
if (mode == GAMIN_FLOWCONTROLSTART) { | if (mode == GAMIN_FLOWCONTROLSTART) { |
|
GAM_DEBUG(DEBUG_INFO, "inotify: GAMIN_FLOWCONTROLSTART for %s\n", data->path); |
if (data->wd >= 0) { | if (data->wd >= 0) { |
if (ioctl (inotify_device_fd, INOTIFY_IGNORE, &data->wd) < 0) { | if (ioctl (inotify_device_fd, INOTIFY_IGNORE, &data->wd) < 0) { |
GAM_DEBUG (DEBUG_INFO, "INOTIFY_IGNORE failed for %s (wd = %d)\n", data->path, data->wd); | GAM_DEBUG (DEBUG_INFO, "INOTIFY_IGNORE failed for %s (wd = %d)\n", data->path, data->wd); |
|
|
} | } |
data->busy++; | data->busy++; |
} else { | } else { |
|
GAM_DEBUG(DEBUG_INFO, "inotify: GAMIN_FLOWCONTROLSTOP for %s\n", data->path); |
if (data->busy > 0) { | if (data->busy > 0) { |
|
GAM_DEBUG(DEBUG_INFO, "inotify: data->busy > 0 for %s\n", data->path); |
data->busy--; | data->busy--; |
if (data->busy == 0) { | if (data->busy == 0) { |
|
GAM_DEBUG(DEBUG_INFO, "inotify: data->busy == 0 for %s\n", data->path); |
path_fd = open(data->path, O_RDONLY); | path_fd = open(data->path, O_RDONLY); |
if (path_fd < 0) { | if (path_fd < 0) { |
G_UNLOCK(inotify); | G_UNLOCK(inotify); |
GAM_DEBUG(DEBUG_INFO, | GAM_DEBUG(DEBUG_INFO, |
"Failed to reactivate inotify for %s\n", |
"failed to reactivate inotify for %s\n", |
data->path); | data->path); |
| |
if ((dir != path) && (dir != NULL)) | if ((dir != path) && (dir != NULL)) |
|
|
close (path_fd); | close (path_fd); |
| |
/* Remove the old wd from the hash table */ | /* Remove the old wd from the hash table */ |
g_hash_table_remove(wd_hash, GINT_TO_POINTER(data->wd)); |
g_hash_table_remove(wd_hash, GINT_TO_POINTER(data->wd)); |
| |
data->wd = path_wd; | data->wd = path_wd; |
data->deactivated = FALSE; | data->deactivated = FALSE; |
|
|
/* Insert the new wd into the hash table */ | /* Insert the new wd into the hash table */ |
g_hash_table_insert(wd_hash, GINT_TO_POINTER(data->wd), | g_hash_table_insert(wd_hash, GINT_TO_POINTER(data->wd), |
data); | data); |
GAM_DEBUG(DEBUG_INFO, "Reactivated inotify for %s\n", |
GAM_DEBUG(DEBUG_INFO, "reactivated inotify for %s\n", |
data->path); | data->path); |
#ifdef GAMIN_DEBUG_API | #ifdef GAMIN_DEBUG_API |
gam_debug_report(GAMinotifyFlowOff, path, 0); | gam_debug_report(GAMinotifyFlowOff, path, 0); |
|
|
} | } |
} | } |
} | } |
|
#endif |
if ((dir != path) && (dir != NULL)) | if ((dir != path) && (dir != NULL)) |
g_free(dir); | g_free(dir); |
} else { | } else { |
|
|
| |
data = g_hash_table_lookup (wd_hash, GINT_TO_POINTER(event->wd)); | data = g_hash_table_lookup (wd_hash, GINT_TO_POINTER(event->wd)); |
if (!data) { | if (!data) { |
GAM_DEBUG(DEBUG_INFO, "inotify can't find wd %d\n", event->wd); |
GAM_DEBUG(DEBUG_INFO, "processing event: inotify can't find wd %d\n", event->wd); |
|
} else if (data->deactivated) { |
|
GAM_DEBUG(DEBUG_INFO, "inotify: ignoring event on temporarily deactivated watch %s\n", data->path); |
} else { | } else { |
if (event->mask == IN_IGNORED) { | if (event->mask == IN_IGNORED) { |
GList *l; | GList *l; |
| |
GAM_DEBUG(DEBUG_INFO, "inotify ignoring wd %d\n", event->wd); |
GAM_DEBUG(DEBUG_INFO, "inotify: IN_IGNORE on wd=%d\n", event->wd); |
|
GAM_DEBUG(DEBUG_INFO, "inotify: removing all subscriptions for %s\n", data->path); |
| |
l = data->subs; | l = data->subs; |
data->subs = NULL; | data->subs = NULL; |
|
|
gam_poll_scan_directory (data->path); | gam_poll_scan_directory (data->path); |
} | } |
} else if (event->mask == IN_Q_OVERFLOW) { | } else if (event->mask == IN_Q_OVERFLOW) { |
GAM_DEBUG(DEBUG_INFO, "inotify queue over flowed\n"); |
GAM_DEBUG(DEBUG_INFO, "inotify queue over flowed\n"); |
|
GAM_DEBUG(DEBUG_INFO, "FIXME, should request poll for all paths here\n"); |
} | } |
} | } |
| |