[Xapian-discuss] Terminating a Xapian query
Olly Betts
olly at survex.com
Fri Sep 25 16:19:39 BST 2009
On Fri, Sep 25, 2009 at 04:01:38PM +0100, James Aylett wrote:
> I honestly don't know a huge amount about thread cancellation (ie:
> killing it from the outside of the thread). Xapian wasn't designed
> with this in mind; it generally works by having objects refcounted
> (automatically). If the thread doesn't clean up its stack-allocated
> objects when killed, then it certainly won't work.
>
> Olly or Richard can probably give more guidance on how Xapian works to
> enable you to figure this out.
If you just kill the thread, you're likely to leak memory. The same
goes if you try to use alarm(), setjmp() and longjmp() for similar
reasons, but you can probably manage to close the database if you scope
the jump correctly, so no fd leaks.
I don't have a magic answer to this I'm afraid.
I think the best current approach would be to run the search in a child
process. You could achieve this without having to write much code if
you run the search using the remote backend and xapian-progsrv. If you
only have one database and it is remote, recent versions of Xapian just
run the match remotely and then serialise the results across the link,
so you only add a small overhead. The bit I can't see how to cleanly
implement is finding the pid of the xapian-progsrv so you can kill it...
Cheers,
Olly
More information about the Xapian-discuss
mailing list