src/dbfs/dbfs.h
changeset 41 6abda2fa4579
parent 36 56427f22e969
child 42 40a3b13ffc9d
equal deleted inserted replaced
40:03017f5f0087 41:6abda2fa4579
     7 #include <event2/event.h>
     7 #include <event2/event.h>
     8 
     8 
     9 #include "ops.h"
     9 #include "ops.h"
    10 #include "../evfuse.h"
    10 #include "../evfuse.h"
    11 #include "../evsql.h"
    11 #include "../evsql.h"
       
    12 #include "../lib/error.h"
    12 
    13 
    13 /*
    14 /*
    14  * Structs and functions shared between all dbfs components
    15  * Structs and functions shared between all dbfs components
    15  */
    16  */
    16 
    17 
    20     const char *db_conninfo;
    21     const char *db_conninfo;
    21     struct evsql *db;
    22     struct evsql *db;
    22 
    23 
    23     struct evfuse *ev_fuse;
    24     struct evfuse *ev_fuse;
    24 };
    25 };
    25 
       
    26 // used for error returns
       
    27 typedef int err_t;
       
    28 
    26 
    29 // XXX: not sure how this should work
    27 // XXX: not sure how this should work
    30 #define CACHE_TIMEOUT 1.0
    28 #define CACHE_TIMEOUT 1.0
    31 
    29 
    32 // columns used for stat_info
    30 // columns used for stat_info
    65  *
    63  *
    66  * Note that this does not fill the st_ino field
    64  * Note that this does not fill the st_ino field
    67  */
    65  */
    68 int _dbfs_stat_info (struct stat *st, const struct evsql_result_info *res, size_t row, size_t col_offset);
    66 int _dbfs_stat_info (struct stat *st, const struct evsql_result_info *res, size_t row, size_t col_offset);
    69 
    67 
       
    68 /** interrupt.c 
       
    69  *  
       
    70  * Fuse interrupts are handled using fuse_req_interrupt_func. Calling this registers a callback function with the req,
       
    71  * which may or may not be called either by fuse_req_interrupt_func, or later on via evfuse's event handler. It is
       
    72  * assumed that this will never be called after a call to fuse_reply_*.
       
    73  *
       
    74  * Hence, to handle an interrupt, we must first ensure that fuse_reply_* will not be called afterwards (it'll return
       
    75  * an error), and then we must call fuse_reply_err(req, EINTR).
       
    76  *
       
    77  * In the simplest case, we can simply submit a query, and then abort it once the req is interrupted (now or later).
       
    78  * In the more complicated case, we can check if the request was interrupted, if not, do the query and handle
       
    79  * interrupts.
       
    80  */
       
    81 
       
    82 /*
       
    83  * Useable as a callback to fuse_req_interrupt_func, will abort the given query and err the req.
       
    84  */
       
    85 void dbfs_interrupt_query (struct fuse_req *req, void *query_ptr);
       
    86 
       
    87 /*
       
    88  * XXX: More complicated state, is this actually needed?
       
    89  */
       
    90 struct dbfs_interrupt_ctx {
       
    91     struct fuse_req *req;
       
    92     struct evsql_query *query;
       
    93 
       
    94     int interrupted : 1;
       
    95 };
       
    96 
       
    97 /*
       
    98  * Register as a fuse interrupt function for simple requests that only run one query without allocating any resources.
       
    99  *
       
   100  * This will abort the query if the interrupt is run, causing it's callback to not be called.
       
   101  *
       
   102  * Returns nonzero if the request was already interrupted, zero otherwise. Be careful that the interrupt does not get
       
   103  * fired between you checking for it and setting query.
       
   104  */
       
   105 int dbfs_interrupt_register (struct fuse_req *req, struct dbfs_interrupt_ctx *ctx);
       
   106 
    70 #endif /* DBFS_DBFS_H */
   107 #endif /* DBFS_DBFS_H */