From d5f5babffd6ad42153e07325e9ac169afa64295a Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 17 Oct 2005 15:10:52 +0000 Subject: fix --- ChangeLog | 4 ++++ sshfs.c | 13 ++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe5fd32..0439a59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-10-17 Miklos Szeredi + + * Add one more missing lock. + 2005-10-15 Miklos Szeredi * Protect request ID allocation with mutex. Bug report by Tvrtko diff --git a/sshfs.c b/sshfs.c index e0b8b99..d69c5f0 100644 --- a/sshfs.c +++ b/sshfs.c @@ -940,10 +940,10 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf, req->data = data; sem_init(&req->ready, 0, 0); buf_init(&req->reply, 0); - if (begin_func) - begin_func(req); buf_init(&buf2, buf->len + 4); pthread_mutex_lock(&lock); + if (begin_func) + begin_func(req); id = sftp_get_id(); buf_add_uint32(&buf2, id); buf_add_mem(&buf2, buf->p, buf->len); @@ -1012,8 +1012,11 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf, } out: - if (end_func) + if (end_func) { + pthread_mutex_lock(&lock); end_func(req); + pthread_mutex_unlock(&lock); + } buf_free(&buf2); request_free(req); return err; @@ -1447,9 +1450,7 @@ static void sshfs_read_end(struct request *req) static void sshfs_read_begin(struct request *req) { struct read_chunk *chunk = (struct read_chunk *) req->data; - pthread_mutex_lock(&lock); chunk->refs++; - pthread_mutex_unlock(&lock); } static int sshfs_send_async_read(struct sshfs_file *sf, @@ -1586,9 +1587,7 @@ static int sshfs_read(const char *path, char *rbuf, size_t size, off_t offset, static void sshfs_write_begin(struct request *req) { struct sshfs_file *sf = (struct sshfs_file *) req->data; - pthread_mutex_lock(&lock); list_add(&req->list, &sf->write_reqs); - pthread_mutex_unlock(&lock); } static void sshfs_write_end(struct request *req) -- cgit v1.2.3