aboutsummaryrefslogtreecommitdiff
path: root/lib/fuse_loop_mt.c
diff options
context:
space:
mode:
authorGravatar Miklos Szeredi <mszeredi@suse.cz>2013-06-21 18:17:27 +0200
committerGravatar Miklos Szeredi <mszeredi@suse.cz>2013-06-21 18:17:27 +0200
commit561d7054d856eea6c2d634093546d6af773dada9 (patch)
tree834081dc3e406f37af0f2c00d3d6ca515f217738 /lib/fuse_loop_mt.c
parent5334a152e1272a072339fb4519de04ed4269d3ca (diff)
libfuse: remove fuse_chan_bufsize()
Remove fuse_chan_bufsize() from the lowlevel API. fuse_session_receive_buf() is now responsible for allocating memory for the buffer.
Diffstat (limited to 'lib/fuse_loop_mt.c')
-rw-r--r--lib/fuse_loop_mt.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c
index b53a868..b146d73 100644
--- a/lib/fuse_loop_mt.c
+++ b/lib/fuse_loop_mt.c
@@ -28,7 +28,7 @@ struct fuse_worker {
struct fuse_worker *next;
pthread_t thread_id;
size_t bufsize;
- char *buf;
+ struct fuse_buf fbuf;
struct fuse_mt *mt;
};
@@ -70,14 +70,10 @@ static void *fuse_do_work(void *data)
while (!fuse_session_exited(mt->se)) {
int isforget = 0;
- struct fuse_buf fbuf = {
- .mem = w->buf,
- .size = w->bufsize,
- };
int res;
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- res = fuse_session_receive_buf(mt->se, &fbuf, mt->prevch);
+ res = fuse_session_receive_buf(mt->se, &w->fbuf, mt->prevch);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if (res == -EINTR)
continue;
@@ -99,8 +95,8 @@ static void *fuse_do_work(void *data)
* This disgusting hack is needed so that zillions of threads
* are not created on a burst of FORGET messages
*/
- if (!(fbuf.flags & FUSE_BUF_IS_FD)) {
- struct fuse_in_header *in = fbuf.mem;
+ if (!(w->fbuf.flags & FUSE_BUF_IS_FD)) {
+ struct fuse_in_header *in = w->fbuf.mem;
if (in->opcode == FUSE_FORGET ||
in->opcode == FUSE_BATCH_FORGET)
@@ -113,7 +109,7 @@ static void *fuse_do_work(void *data)
fuse_loop_start_thread(mt);
pthread_mutex_unlock(&mt->lock);
- fuse_session_process_buf(mt->se, &fbuf, mt->prevch);
+ fuse_session_process_buf(mt->se, &w->fbuf, mt->prevch);
pthread_mutex_lock(&mt->lock);
if (!isforget)
@@ -129,7 +125,7 @@ static void *fuse_do_work(void *data)
pthread_mutex_unlock(&mt->lock);
pthread_detach(w->thread_id);
- free(w->buf);
+ free(w->fbuf.mem);
free(w);
return NULL;
}
@@ -183,18 +179,11 @@ static int fuse_loop_start_thread(struct fuse_mt *mt)
return -1;
}
memset(w, 0, sizeof(struct fuse_worker));
- w->bufsize = fuse_chan_bufsize(mt->prevch);
- w->buf = malloc(w->bufsize);
+ w->fbuf.mem = NULL;
w->mt = mt;
- if (!w->buf) {
- fprintf(stderr, "fuse: failed to allocate read buffer\n");
- free(w);
- return -1;
- }
res = fuse_start_thread(&w->thread_id, fuse_do_work, w);
if (res == -1) {
- free(w->buf);
free(w);
return -1;
}
@@ -211,7 +200,7 @@ static void fuse_join_worker(struct fuse_mt *mt, struct fuse_worker *w)
pthread_mutex_lock(&mt->lock);
list_del_worker(w);
pthread_mutex_unlock(&mt->lock);
- free(w->buf);
+ free(w->fbuf.mem);
free(w);
}