Date: Tue, 06 Mar 2012 17:18:39 +0400 From: Sergey Matveychuk <sem@semmy.ru> To: Markiyan Kushnir <markiyan.kushnir@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: watching for a directory with kqueue Message-ID: <4F560EAF.40001@semmy.ru> In-Reply-To: <4F5528BF.9030109@gmail.com> References: <4F550227.2010006@FreeBSD.org> <4F5528BF.9030109@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
06.03.2012 0:57, Markiyan Kushnir wrote: > On 05.03.2012 20:12, Sergey Matveychuk wrote: >> Hi. >> >> I've met a problem with the subj. Could you help? >> >> I'm watching for a directory: >> EV_SET(kq_change_list, fd, EVFILT_VNODE, >> EV_ADD | EV_ENABLE | EV_ONESHOT, >> NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB, >> 0, 0); >> >> When the directory changed, I read its contens with opendir, like that: >> struct kq_event kq_event[1000]; >> ... >> while(1) { >> n = kevent(kq, kq_change_list, chlist_used, kq_event, 1000, NULL); >> for(i = 0; i < n; i++) { >> if(kq_event[i].fflags & NOTE_EXTEND || kq_event[i].fflags & NOTE_WRITE) { >> opendir(.....) >> >> It works when I create a few files (1-3), but when I create 10 files >> with touch(1) I see only 3-6 files with opendir. I've got only one event >> with kevent() (n=1). Looks like I should got a few events, but I did >> not. Could you give an advice how to get all created files? > > Try to put some delay (~10ms) after your call to kevent(). > Not enough smooth for me, but works.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F560EAF.40001>