bdkjones / vdkqueue Goto Github PK
View Code? Open in Web Editor NEWA modern, streamlined, faster version of UKKQueue
A modern, streamlined, faster version of UKKQueue
// I was receiving about 3 EXC_BAD_ACCESS (SIGSEGV) crash reports a month that listed the 'path' objc_msgSend
A sequence which will generate this is:
VDKQueue deallocs
_keepWatcherThreadRunning = NO
[self removeAllPaths];
At that point all entries's are deallocated.
Meanwhile the thread is stuck in kevent
An event happens on the file
the thread reads the event, retrieves the dangling entry pointer from ev.udata
crash ensues
Multithreading is hard.
A bandaid solution would be to add
if ( !_keepWatcherThreadRunning ) break;
after the kevent, that will minimise the period where the dealloc can happen, but it will still be possible, just far less likely.
Really the events need to be retained by the thread as well and only released when the thread completes, or otherwise the entries need to be validated or looked for some other way that avoids leaving a dangling pointer.
First off - great to see UKKQueue ready for 64 bit (yeah, I'm a bit behind) and using GCD, thanks!
If you turn on the -Wextra
compiler warning flag when building VDKQueue, you get a few warnings about semicolons at the end of files (e.g. VDKQueue.m:L54) and about unknown pragmas (e.g. VDKQueue.m:L30,31)
Not a big issue, but would you be able to fix these warnings, just so that things look a little nicer when I build my projects.
Happy to send a pull request if you want
Thanks!
Hi
I trying to use VDKQueue, with XCode 4.3.3, OS X 10.7.4
I've tried use addPath method, and implement VDKQueueDelegate class with a callback method.
every time I try to run it I got a compile error :
Undefined symbols for architecture x86_64:
"OBJC_CLASS$_VDKQueue", referenced from:
objc-class-ref in AppDelegate.o
(maybe you meant: OBJC_CLASS$_VDKQueueDelegate)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
just curious, can I use VDKQueue in 64 bit ?
Thanks,
Alfian
I have tried the code, when I add a "path" to be monitored, it works file , but if I add a "file" to be monitored, it seems working wrong. for example, if I edit a file and save it, I can only get one "DELETE" operation for ONLY ONE time...and then no matter I try, no response.
As you are probably aware, once the watcher thread has been started, there is no way to dealloc the VDKQueue object. This is because detachThread retains the target (which is "self"), so the retainCount is 2. Unless you provide a way to stop the thread, the object can never be released! Even worse, if the object was created by its delegate, and the delegate goes away, it will try to send messages to the delegate, causing a crash.
The fix I'm using is to add a new method (stopWatching:) which sets _keepWatcherThreadRunning to NO and removes all the watched path entries, then require the client to call it before calling release.
Hi I have a possibly silly question.
I want to monitor a folder and get notified when there is any files added, deleted. modified.
with VDKQueue, I think I could get the notification.
But how to get the file names which are newly added, deleted, modified?
BRs,
Zongyao Qu
I think it's because of Foundation being built with ARC enabled. This makes it so that some objects that weren't going through an autorelease pool now do, causing the NSThread to leak those objects.
malloc_history
proof :
ALLOC 0x136429270-0x1364292ff [size=144]: thread_115b04000 |-[VDKQueue
watcherThread:] | -[NSObject(NSObject) autorelease] |
_CFAutoreleasePoolAddObject | CFLog | _CFLogvEx |
_CFStringCreateWithFormatAndArgumentsAux | CFStringCreateCopy |
__CFStringCreateImmutableFunnel3 | _CFRuntimeCreateInstance |
malloc_zone_malloc
----
FREE 0x136429270-0x1364292ff [size=144]: thread_115b04000 |-[VDKQueue
watcherThread:] | -[NSObject(NSObject) autorelease] |
_CFAutoreleasePoolAddObject | CFLog | _CFLogvEx | _CFRelease |
malloc_zone_free
Hi
Im not sure if this is where im supposed to ask about this stuff?
In any case. I have my code set up like this, and it will catch the first modification of the file and it returns 3 notifications (http://pastebin.com/WC2jn9Vk), but if I modify the file again it doesn't seem to change the value of n = kevent(theFD, NULL, 0, &ev, 1, &timeout);
Any help would be greatly appreciated!
VDKQueue *kqueue = [[VDKQueue alloc] init];
kqueue.delegate = self;
[kqueue addPath:path notifyingAbout:VDKQueueNotifyDefault];
-(void) VDKQueue:(VDKQueue )queue receivedNotification:(NSString)noteName forPath:(NSString*)fpath{
//Doing Stuff
}
Would you be open to the idea of making VDKQueue available under a GPL-compatible free software license, such as the 3-Clause BSD License, which is similar to your current license?
I'm a dev on the Transmission BitTorrent client, and the current license's "Be Awesome" clause could be problematic for us if we switch to VDKQueue. Transmission is bundled on several Linux distros that want software that has no restrictions, even well-intentioned like "Be Awesome", on its use.
It should be a laughing matter but unfortunately it's not. As described at https://trac.transmissionbt.com/ticket/5131, we recently switched Transmission's JSON parser because the old one's license is considered nonfree by the FSF and Debian due to its use restrictions: "This Software shall be used for Good, not Evil."
I'm using VDKQueue on OS X 10.7.3 in xCode 4.2 and I get a "Use of Undeclared Identifier" error on VDKQueueNotifyDefault when I try to run the following code:
VDKQueue* kqueue = [[VDKQueue alloc] init];
[kqueue addPath:@"/path/to/directory/" notifyingAbout:VDKQueueNotifyDefault];
It's actually providing undeclared identifier errors on all the u_int flags in VDKQueue.h. When I call just the "addPath" method everything works fine.
Letting know the community that I'll be maintaining a fork with various bugfixes:
https://github.com/coeur/VDKQueue
The code of this fork was used in apps like https://github.com/transmission/transmission, so it's well reviewed and tested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.