| author | Tero Marttila <terom@fixme.fi> |
| Fri, 28 Nov 2008 23:46:11 +0200 | |
| branch | new-evsql |
| changeset 45 | 424ce5ab82fd |
| parent 44 | 9e76ee9729b6 |
| child 48 | 8b019d191353 |
| permissions | -rw-r--r-- |
|
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:
diff
changeset
|
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:
diff
changeset
|
2 |
#include "dbfs.h" |
|
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:
diff
changeset
|
3 |
|
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
4 |
void _dbfs_interrupt_reply (evutil_socket_t _unused1, short _unused2, void *req_ptr) {
|
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
5 |
struct fuse_req *req = req_ptr; |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
6 |
err_t err; |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
7 |
|
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
8 |
// error the req |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
9 |
if ((err = -fuse_reply_err(req, EINTR))) |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
10 |
EWARNING(err, "fuse_reply_err"); |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
11 |
} |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
12 |
|
|
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:
diff
changeset
|
13 |
void dbfs_interrupt_query (struct fuse_req *req, void *query_ptr) {
|
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
14 |
struct dbfs *ctx = fuse_req_userdata(req); |
|
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:
diff
changeset
|
15 |
struct evsql_query *query = query_ptr; |
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
16 |
struct timeval tv; |
|
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:
diff
changeset
|
17 |
err_t err; |
|
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:
diff
changeset
|
18 |
|
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
19 |
// abort query |
|
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:
diff
changeset
|
20 |
evsql_query_abort(NULL, query); |
|
44
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
21 |
|
|
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
22 |
// error the req |
|
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
23 |
if ((err = -fuse_reply_err(req, EINTR))) |
|
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
24 |
EWARNING(err, "fuse_reply_err"); |
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
25 |
|
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
26 |
/* |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
27 |
* Due to a locking bug in libfuse (at least 2.7.4), we can't call fuse_reply_err from the interrupt function, so we must |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
28 |
* schedule after this function returns. |
|
44
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
29 |
* / |
|
42
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
30 |
tv.tv_sec = 0; |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
31 |
tv.tv_usec = 0; |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
32 |
if (event_base_once(ctx->ev_base, -1, EV_TIMEOUT, _dbfs_interrupt_reply, req, &tv)) |
|
40a3b13ffc9d
defer fuse_reply_err using event_base_once, interrupt happens without deadlock now
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
33 |
PWARNING("event_base_once failed, dropping req reply: %p", req);
|
|
44
9e76ee9729b6
more work on the new evsql interface
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
34 |
*/ |
|
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:
diff
changeset
|
35 |
} |
|
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:
diff
changeset
|
36 |
|
|
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:
diff
changeset
|
37 |
void _dbfs_interrupt_ctx (struct fuse_req *req, void *ctx_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:
diff
changeset
|
38 |
// dereference 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:
diff
changeset
|
39 |
struct dbfs_interrupt_ctx *ctx = ctx_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:
diff
changeset
|
40 |
|
|
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:
diff
changeset
|
41 |
// just cancel query if pending |
|
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:
diff
changeset
|
42 |
if (ctx->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:
diff
changeset
|
43 |
evsql_query_abort(NULL, ctx->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:
diff
changeset
|
44 |
ctx->query = NULL; |
|
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:
diff
changeset
|
45 |
} |
|
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:
diff
changeset
|
46 |
|
|
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:
diff
changeset
|
47 |
// mark as interrupted |
|
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:
diff
changeset
|
48 |
ctx->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:
diff
changeset
|
49 |
} |
|
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:
diff
changeset
|
50 |
|
|
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:
diff
changeset
|
51 |
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:
diff
changeset
|
52 |
// initialize |
|
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:
diff
changeset
|
53 |
ctx->query = NULL; |
|
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:
diff
changeset
|
54 |
ctx->interrupted = 0; |
|
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:
diff
changeset
|
55 |
|
|
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:
diff
changeset
|
56 |
// just pass over to fuse_req_interrupt_func |
|
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:
diff
changeset
|
57 |
fuse_req_interrupt_func(req, _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:
diff
changeset
|
58 |
} |