Author: tridge Date: 2006-04-05 04:50:08 +0000 (Wed, 05 Apr 2006) New Revision: 14918
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14918 Log: cleaner handling of systems without inotify Modified: branches/SAMBA_4_0/source/ntvfs/common/notify.c branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c Changeset: Modified: branches/SAMBA_4_0/source/ntvfs/common/notify.c =================================================================== --- branches/SAMBA_4_0/source/ntvfs/common/notify.c 2006-04-05 04:44:13 UTC (rev 14917) +++ branches/SAMBA_4_0/source/ntvfs/common/notify.c 2006-04-05 04:50:08 UTC (rev 14918) @@ -268,6 +268,25 @@ } /* + add an entry to the notify array +*/ +static NTSTATUS notify_add_array(struct notify_context *notify, struct notify_entry *e, + const char *path, void *private) +{ + notify->array->entries[notify->array->num_entries] = *e; + notify->array->entries[notify->array->num_entries].private = private; + notify->array->entries[notify->array->num_entries].server = notify->server; + + if (path) { + notify->array->entries[notify->array->num_entries].path = path; + } + + notify->array->num_entries++; + + return notify_save(notify); +} + +/* add a notify watch. This is called when a notify is first setup on a open directory handle. */ @@ -312,34 +331,24 @@ DLIST_ADD(notify->list, listel); /* ignore failures from sys_notify */ - status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, - sys_notify_callback, listel, - &listel->sys_notify_handle); - if (NT_STATUS_IS_OK(status)) { - talloc_steal(listel, listel->sys_notify_handle); - notify_unlock(notify); - } else { - notify->array->entries[notify->array->num_entries] = *e; - notify->array->entries[notify->array->num_entries].private = private; - notify->array->entries[notify->array->num_entries].server = notify->server; - - if (path) { - notify->array->entries[notify->array->num_entries].path = path; + if (notify->sys_notify_ctx != NULL) { + status = sys_notify_watch(notify->sys_notify_ctx, e->path, e->filter, + sys_notify_callback, listel, + &listel->sys_notify_handle); + if (NT_STATUS_IS_OK(status)) { + /* if the kernel handler has said it can handle this notify then + we don't need to add it to the array */ + talloc_steal(listel, listel->sys_notify_handle); + goto done; } + } - notify->array->num_entries++; + status = notify_add_array(notify, e, path, private); - status = notify_save(notify); +done: + notify_unlock(notify); + talloc_free(path); - notify_unlock(notify); - - NT_STATUS_NOT_OK_RETURN(status); - } - - if (path) { - talloc_free(path); - } - return status; } Modified: branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c =================================================================== --- branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c 2006-04-05 04:44:13 UTC (rev 14917) +++ branches/SAMBA_4_0/source/ntvfs/sysdep/inotify.c 2006-04-05 04:50:08 UTC (rev 14918) @@ -239,7 +239,7 @@ /* add a watch. The watch is removed when the caller calls - talloc_free() on handle + talloc_free() on *handle */ static NTSTATUS inotify_watch(struct sys_notify_context *ctx, const char *dirpath, uint32_t filter, sys_notify_callback_t callback, Modified: branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c =================================================================== --- branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c 2006-04-05 04:44:13 UTC (rev 14917) +++ branches/SAMBA_4_0/source/ntvfs/sysdep/sys_notify.c 2006-04-05 04:50:08 UTC (rev 14918) @@ -44,6 +44,10 @@ const char *bname; struct sys_notify_backend *b; + if (backends == NULL) { + return NULL; + } + if (ev == NULL) { ev = event_context_find(mem_ctx); }