src/dbfs/interrupt.c
author Tero Marttila <terom@fixme.fi>
Tue, 18 Nov 2008 01:55:13 +0200
changeset 41 6abda2fa4579
child 42 40a3b13ffc9d
permissions -rw-r--r--
touch up the Makefile, define err_t as unsigned int in error.h, and add some preliminary interrupt support, although it will always deadlock due to a bug in libfuse

#include "dbfs.h"

void dbfs_interrupt_query (struct fuse_req *req, void *query_ptr) {
    struct evsql_query *query = query_ptr;
    err_t err;

    // abort
    evsql_query_abort(NULL, query);

    // error the req
    if ((err = -fuse_reply_err(req, EINTR)))
        PWARNING("fuse_reply_err", err);
}

void _dbfs_interrupt_ctx (struct fuse_req *req, void *ctx_ptr) {
    // dereference ctx
    struct dbfs_interrupt_ctx *ctx = ctx_ptr;
    
    // just cancel query if pending
    if (ctx->query) {
        evsql_query_abort(NULL, ctx->query);
        ctx->query = NULL;
    }

    // mark as interrupted
    ctx->interrupted = 1;
}

int dbfs_interrupt_register (struct fuse_req *req, struct dbfs_interrupt_ctx *ctx) {
    // initialize
    ctx->query = NULL;
    ctx->interrupted = 0;

    // just pass over to fuse_req_interrupt_func
    fuse_req_interrupt_func(req, _dbfs_interrupt_ctx, ctx);
}