Skip to content

Commit

Permalink
Add missing mutex lock/unlocks when accessing conntab
Browse files Browse the repository at this point in the history
(problem introduced in parent commit).
  • Loading branch information
Nikratio committed Nov 27, 2019
1 parent 8822b60 commit 28c2227
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2499,11 +2499,13 @@ static int sshfs_rename(const char *from, const char *to, unsigned int flags)
err = -EXDEV;

if (!err && sshfs.max_conns > 1) {
pthread_mutex_lock(&sshfs.lock);
void *conn = g_hash_table_lookup(sshfs.conntab, from);
if (conn != NULL) {
g_hash_table_replace(sshfs.conntab, g_strdup(to), conn);
g_hash_table_remove(sshfs.conntab, from);
}
pthread_mutex_unlock(&sshfs.lock);
}

return err;
Expand Down Expand Up @@ -2849,6 +2851,7 @@ static int sshfs_release(const char *path, struct fuse_file_info *fi)
buf_free(handle);
chunk_put_locked(sf->readahead);
if (sshfs.max_conns > 1) {
pthread_mutex_lock(&sshfs.lock);
sf->conn->file_count--;
if(!sf->conn->file_count)
g_hash_table_remove(sshfs.conntab, path);
Expand Down

0 comments on commit 28c2227

Please sign in to comment.