From 0358c96422e74786ec03b914baab4195e38a50f5 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 17 Oct 2005 12:57:52 +0000 Subject: fix --- ChangeLog | 5 +++++ sshfs.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed75569..fe5fd32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-10-15 Miklos Szeredi + + * Protect request ID allocation with mutex. Bug report by Tvrtko + Ursulin + 2005-08-17 Miklos Szeredi * Try to calculate approximate disk usage of files from their diff --git a/sshfs.c b/sshfs.c index 53b0ea3..eca3369 100644 --- a/sshfs.c +++ b/sshfs.c @@ -933,13 +933,9 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf, { int err; struct buffer buf2; - uint32_t id = sftp_get_id(); + uint32_t id; struct request *req = g_new0(struct request, 1); - buf_init(&buf2, buf->len + 4); - buf_add_uint32(&buf2, id); - buf_add_mem(&buf2, buf->p, buf->len); - req->want_reply = expect_type != 0 ? 1 : 0; req->end_func = end_func; req->data = data; @@ -947,7 +943,11 @@ static int sftp_request_common(uint8_t type, const struct buffer *buf, buf_init(&req->reply, 0); if (begin_func) begin_func(req); + buf_init(&buf2, buf->len + 4); pthread_mutex_lock(&lock); + id = sftp_get_id(); + buf_add_uint32(&buf2, id); + buf_add_mem(&buf2, buf->p, buf->len); err = start_processing_thread(); if (err) { pthread_mutex_unlock(&lock); -- cgit v1.2.3