From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 6 13:18:42 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96284106564A for ; Tue, 6 Mar 2012 13:18:42 +0000 (UTC) (envelope-from sem@semmy.ru) Received: from sunner.semmy.ru (sunner.semmy.ru [IPv6:2a00:14d0:0:20::3]) by mx1.freebsd.org (Postfix) with ESMTP id 252368FC15 for ; Tue, 6 Mar 2012 13:18:41 +0000 (UTC) Received: from dhcp170-40-red.yandex.net ([95.108.170.40]) by sunner.semmy.ru with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1S4uHn-000FLp-LA; Tue, 06 Mar 2012 17:18:39 +0400 Message-ID: <4F560EAF.40001@semmy.ru> Date: Tue, 06 Mar 2012 17:18:39 +0400 From: Sergey Matveychuk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: Markiyan Kushnir References: <4F550227.2010006@FreeBSD.org> <4F5528BF.9030109@gmail.com> In-Reply-To: <4F5528BF.9030109@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 06 Mar 2012 13:41:11 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: watching for a directory with kqueue X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2012 13:18:42 -0000 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.