68 debug ( 30,
"pthread_spin_lock(&queue_lock);" );
84 debug ( 30,
"pthread_spin_unlock(&queue_lock);" );
92 debug ( 30,
"pthread_spin_lock(&queue_lock);" );
96 debug ( 30,
"pthread_spin_unlock(&queue_lock);" );
102 GFileMonitor *filemon,
105 GFileMonitorEvent
event,
112 GFileType filetype = g_file_query_file_type ( file, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, NULL );
113 debug ( 10,
"%p %p %p %i %p %i", filemon, file, file_other,
event, arg, filetype );
114 char *path_full, *path_rel = NULL;
117 case G_FILE_MONITOR_EVENT_DELETED:
118 case G_FILE_MONITOR_EVENT_CREATED:
119 case G_FILE_MONITOR_EVENT_CHANGED:
120 case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
121 path_full = g_file_get_path ( file );
123 g_free ( path_full );
124 debug ( 9,
"Got event %i for \"%s\" (%i)",
event, path_rel, filetype );
131 switch ( filetype ) {
132 case G_FILE_TYPE_DIRECTORY:
142 case G_FILE_MONITOR_EVENT_DELETED:
147 case G_FILE_MONITOR_EVENT_CREATED:
159 case G_FILE_MONITOR_EVENT_DELETED:
160 debug ( 20,
"g_hash_table_remove(mondirs_ht, \"%s\")", path_rel );
163 case G_FILE_MONITOR_EVENT_CREATED:
164 case G_FILE_MONITOR_EVENT_CHANGED:
165 case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
169 debug ( 20,
"event_push(\"%s\", %i, %i, %i, %i, %i)", path_rel, fmdat->
handle_id,
event, objtype,
objtype_old,
objtype_new );
184 GError *
error = NULL;
185 debug ( 3,
"\"%s\"", accpath );
187 fmdat = g_hash_table_lookup (
mondirs_ht, accpath );
189 if ( fmdat != NULL ) {
191 warning (
"Directory \"%s\" is already monitored.", accpath );
196 fmdat = xmalloc (
sizeof ( *fmdat ) );
198 fmdat->
file = g_file_new_for_path ( accpath );
201 g_hash_table_replace (
mondirs_ht, strdup ( accpath ), fmdat );
209 struct timeval *timeout_p = _timeout_p;
210 struct timeval tv_abs, timeout_abs;
211 struct timespec ts_abs;
212 debug ( 10,
"{%u, %u}", timeout_p->tv_sec, timeout_p->tv_usec );
220 #define INFINITETIME (3600 * 24 * 365 * 10)
226 gettimeofday ( &tv_abs, NULL );
227 timeradd ( &tv_abs, timeout_p, &timeout_abs );
228 ts_abs.tv_sec = timeout_abs.tv_sec;
229 ts_abs.tv_nsec = timeout_abs.tv_usec * 1000;
230 debug ( 10,
"{%u, %u}", ts_abs.tv_sec, ts_abs.tv_nsec );
238 critical (
"Got error while pthread_cond_timedwait(&gio_cond_gotevent, &gio_mutex_prefetcher, &ts_abs)" );
241 g_main_context_wakeup ( NULL );
243 debug ( 10,
"return" );
253 debug ( 3,
"(ctx_p, indexes_p, %p {%u, %u})", tv_p, tv_p == NULL ? -1 : tv_p->tv_sec, tv_p == NULL ? 0 : tv_p->tv_usec );
263 if ( tv_p->tv_sec == 0 && tv_p->tv_usec == 0 ) {
264 g_main_context_iteration ( NULL, FALSE );
285 debug ( 20,
"g_main_context_iteration(NULL, TRUE); queue_length == %i",
queue_length );
286 result = g_main_context_iteration ( NULL, TRUE );
287 debug ( 10,
"g_main_context_iteration() -> %i", result );
301 debug ( 30,
"pthread_spin_lock(&queue_lock);" );
304 debug ( 30,
"pthread_spin_unlock(&queue_lock);" );
311 static struct timeval tv = {0};
313 char *path_full = NULL;
314 size_t path_full_len = 0;
329 st_mode = lst.st_mode;
330 st_size = lst.st_size;
334 if (
sync_prequeue_loadmark ( 1,
ctx_p, indexes_p, NULL, ev->
path, lst_p, ev->
objtype_old, ev->
objtype_new, ev->
event_id, ev->
handle_id, st_mode, st_size, &path_full, &path_full_len, NULL ) ) {
358 g_signal_handler_disconnect ( fmdat->
file, fmdat->
handle_id );
359 free ( fmdat->
file );
373 pthread_spin_init ( &
queue_lock, PTHREAD_PROCESS_SHARED );
375 gio_loop = g_main_loop_new ( NULL, TRUE );
376 g_main_context_iteration ( NULL, FALSE );