author | Tero Marttila <terom@fixme.fi> |
Sat, 29 Nov 2008 01:30:43 +0200 | |
branch | new-evsql |
changeset 49 | bb2ff0d2d343 |
parent 48 | 8b019d191353 |
permissions | -rw-r--r-- |
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef DBFS_DBFS_H |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define DBFS_DBFS_H |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
#include <sys/stat.h> |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
#include <errno.h> |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
#include <event2/event.h> |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
#include "ops.h" |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
#include "../evfuse.h" |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
#include "../evsql.h" |
41
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
12 |
#include "../lib/error.h" |
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
/* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
* Structs and functions shared between all dbfs components |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
*/ |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
struct dbfs { |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
struct event_base *ev_base; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
21 |
const char *db_conninfo; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
struct evsql *db; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
struct evfuse *ev_fuse; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
}; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
// XXX: not sure how this should work |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
#define CACHE_TIMEOUT 1.0 |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
/* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
* Convert the CHAR(4) inodes.type from SQL into a mode_t. |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
* Returns zero for unknown types. |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
*/ |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
mode_t _dbfs_mode (const char *type); |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
/* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
* Check that the number of rows and columns in the result set matches what we expect. |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
* If rows is nonzero, there must be exactly that many rows (mostly useful for rows=1). |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
* The number of columns must always be given, and match. |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
* Returns; |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
* -1 if the query failed, the columns/rows do not match |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
* 0 the results match |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
46 |
* 1 there were no results (zero rows) |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
*/ |
48
8b019d191353
update dbfs code to work with new evsql
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
48 |
int _dbfs_check_res (struct evsql_result *res, size_t rows, size_t cols); |
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
|
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
/* |
36
56427f22e969
tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
51 |
* Same as _dbfs_check_res, but returns ENOENT/EIO directly |
56427f22e969
tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
52 |
*/ |
48
8b019d191353
update dbfs code to work with new evsql
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
53 |
err_t dbfs_check_result (struct evsql_result *res, size_t rows, size_t cols); |
36
56427f22e969
tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
54 |
|
56427f22e969
tweak debug/info output, implement dbfs_unlink with slightly improved error macros handling
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
55 |
/* |
49
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
56 |
* Stat fields |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
57 |
*/ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
58 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
59 |
// columns used for stat_info |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
60 |
#define DBFS_STAT_COLS " inodes.type, inodes.mode, dbfs_size(inodes.type, inodes.data, inodes.link_path), (SELECT COUNT(*) FROM inodes i LEFT JOIN file_tree ft ON (i.ino = ft.ino) WHERE i.ino = inodes.ino) AS nlink" |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
61 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
62 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
63 |
#define DBFS_STAT_RESULT_INFO \ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
64 |
{ EVSQL_FMT_BINARY, EVSQL_TYPE_STRING }, \ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
65 |
{ EVSQL_FMT_BINARY, EVSQL_TYPE_UINT16 }, \ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
66 |
{ EVSQL_FMT_BINARY, EVSQL_TYPE_UINT32 }, \ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
67 |
{ EVSQL_FMT_BINARY, EVSQL_TYPE_UINT64 } |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
68 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
69 |
struct dbfs_stat_values { |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
70 |
const char *type; |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
71 |
uint16_t mode; |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
72 |
uint32_t size; |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
73 |
uint64_t nlink; |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
74 |
}; |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
75 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
76 |
#define DBFS_STAT_RESULT_VALUES(ptr) \ |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
77 |
&(ptr)->type, &(ptr)->mode, &(ptr)->size, &(ptr)->nlink |
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
78 |
|
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
79 |
/* |
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
80 |
* Fill a `struct state` with info retrieved from a SQL query. |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
81 |
* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
82 |
* The result must contain four columns, starting at the given offset: |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
83 |
* inodes.type, inodes.mode, inodes.size, count(*) AS nlink |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
84 |
* |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
85 |
* Note that this does not fill the st_ino field |
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
86 |
*/ |
49
bb2ff0d2d343
modify stat-returning dbfs result functions to use new evsql
Tero Marttila <terom@fixme.fi>
parents:
48
diff
changeset
|
87 |
int _dbfs_stat_info (struct stat *st, struct dbfs_stat_values *values); |
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
88 |
|
41
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
89 |
/** interrupt.c |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
90 |
* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
91 |
* Fuse interrupts are handled using fuse_req_interrupt_func. Calling this registers a callback function with the req, |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
92 |
* which may or may not be called either by fuse_req_interrupt_func, or later on via evfuse's event handler. It is |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
93 |
* assumed that this will never be called after a call to fuse_reply_*. |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
94 |
* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
95 |
* Hence, to handle an interrupt, we must first ensure that fuse_reply_* will not be called afterwards (it'll return |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
96 |
* an error), and then we must call fuse_reply_err(req, EINTR). |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
97 |
* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
98 |
* In the simplest case, we can simply submit a query, and then abort it once the req is interrupted (now or later). |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
99 |
* In the more complicated case, we can check if the request was interrupted, if not, do the query and handle |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
100 |
* interrupts. |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
101 |
*/ |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
102 |
|
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
103 |
/* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
104 |
* Useable as a callback to fuse_req_interrupt_func, will abort the given query and err the req. |
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
105 |
* |
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
106 |
* Due to a locking bug in libfuse 2.7.4, this will actually delay the fuse_req_err until the next event-loop iteration. |
41
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
107 |
*/ |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
108 |
void dbfs_interrupt_query (struct fuse_req *req, void *query_ptr); |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
109 |
|
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
110 |
/* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
111 |
* XXX: More complicated state, is this actually needed? |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
112 |
*/ |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
113 |
struct dbfs_interrupt_ctx { |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
114 |
struct fuse_req *req; |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
115 |
struct evsql_query *query; |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
116 |
|
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
117 |
int interrupted : 1; |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
118 |
}; |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
119 |
|
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
120 |
/* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
121 |
* Register as a fuse interrupt function for simple requests that only run one query without allocating any resources. |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
122 |
* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
123 |
* This will abort the query if the interrupt is run, causing it's callback to not be called. |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
124 |
* |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
125 |
* Returns nonzero if the request was already interrupted, zero otherwise. Be careful that the interrupt does not get |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
126 |
* fired between you checking for it and setting query. |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
127 |
*/ |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
128 |
int dbfs_interrupt_register (struct fuse_req *req, struct dbfs_interrupt_ctx *ctx); |
6abda2fa4579
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
Tero Marttila <terom@fixme.fi>
parents:
36
diff
changeset
|
129 |
|
29
5de62ca9a5aa
reorganize evsql into a separate dir, rename dbfs slightly, and split dbfs_op out from dirop (in prep for fileop)
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
#endif /* DBFS_DBFS_H */ |