Skip to content

Commit

Permalink
initialize mutex to fix lockup
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Sep 7, 2019
1 parent 2dbcd2b commit 50ad648
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libfuse/lib/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
{
size_t i;
size_t size = 0;
size_t size = 0;

for (i = 0; i < bufv->count; i++) {
if (bufv->buf[i].size == SIZE_MAX)
Expand Down Expand Up @@ -229,8 +229,8 @@ static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off,
int dst_is_fd = dst->flags & FUSE_BUF_IS_FD;

if (!src_is_fd && !dst_is_fd) {
void *dstmem = dst->mem + dst_off;
void *srcmem = src->mem + src_off;
char *dstmem = dst->mem + dst_off;
char *srcmem = src->mem + src_off;

if (dstmem != srcmem) {
if (dstmem + len <= srcmem || srcmem + len <= dstmem)
Expand Down
4 changes: 3 additions & 1 deletion libfuse/lib/fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,7 @@ static void fuse_lib_getattr(fuse_req_t req, fuse_ino_t ino,

memset(&buf, 0, sizeof(buf));

path = NULL;
err = (((fi == NULL) || (f->fs->op.fgetattr == NULL)) ?
get_path(f,ino,&path) :
get_path_nullok(f,ino,&path));
Expand Down Expand Up @@ -2711,9 +2712,10 @@ static void fuse_lib_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,

memset(&buf, 0, sizeof(buf));

path = NULL;
err = ((fi == NULL) ?
get_path(f,ino,&path) :
get_path_nullok(f, ino, &path));
get_path_nullok(f,ino,&path));

if (!err) {
struct fuse_intr_data d;
Expand Down
7 changes: 7 additions & 0 deletions src/policy_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ PolicyCache::Value::Value()
PolicyCache::PolicyCache(void)
: timeout(DEFAULT_TIMEOUT)
{
pthread_mutex_init(&_lock,NULL);
}

void
PolicyCache::erase(const char *fusepath_)
{
if(timeout == 0)
return;

pthread_mutex_lock(&_lock);

_cache.erase(fusepath_);
Expand All @@ -56,6 +60,9 @@ PolicyCache::cleanup(const int prob_)
uint64_t now;
map<string,Value>::iterator i;

if(timeout == 0)
return;

if(rand() % prob_)
return;

Expand Down

0 comments on commit 50ad648

Please sign in to comment.