aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2007-12-10 20:25:25 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2007-12-10 20:25:25 +0000
commit501b9f712fa5543bac73976eb4d9e3a503b098ed (patch)
tree9003322324e1f2f6f6a65b9021182c8c0fedaa28
parent37b408459af343a4b7bff9f05eca8e110204eb47 (diff)
downloadsshfs-501b9f712fa5543bac73976eb4d9e3a503b098ed.tar
sshfs-501b9f712fa5543bac73976eb4d9e3a503b098ed.tar.gz
sshfs-501b9f712fa5543bac73976eb4d9e3a503b098ed.tar.bz2
sshfs-501b9f712fa5543bac73976eb4d9e3a503b098ed.zip
Fix crash on writing files
-rw-r--r--ChangeLog7
-rw-r--r--sshfs.c30
2 files changed, 24 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 2080999..9f59cf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
2007-12-10 Miklos Szeredi <miklos@szeredi.h>u
+ * Fix crash on writing files, caused by missing locking around
+ sshfs_file_get()
+
+ * Don't time requests when not debugging
+
* Add subtype support with libfuse >= 2.7.0
* Abort on allocation failure instead of exit
+ * Correctly show default of nodelaysrv workaround in help message
+
2007-05-16 Miklos Szeredi <miklos@szeredi.hu>
* Released 1.8
diff --git a/sshfs.c b/sshfs.c
index 305cc90..5565a4d 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -996,14 +996,16 @@ static int process_one_request(void)
}
pthread_mutex_unlock(&sshfs.lock);
if (req != NULL) {
- struct timeval now;
- unsigned int difftime;
- gettimeofday(&now, NULL);
- difftime = (now.tv_sec - req->start.tv_sec) * 1000;
- difftime += (now.tv_usec - req->start.tv_usec) / 1000;
- DEBUG(" [%05i] %14s %8ubytes (%ims)\n", id,
- type_name(type),
- (unsigned) buf.size + 5, difftime);
+ if (sshfs.debug) {
+ struct timeval now;
+ unsigned int difftime;
+ gettimeofday(&now, NULL);
+ difftime = (now.tv_sec - req->start.tv_sec) * 1000;
+ difftime += (now.tv_usec - req->start.tv_usec) / 1000;
+ DEBUG(" [%05i] %14s %8ubytes (%ims)\n", id,
+ type_name(type),
+ (unsigned) buf.size + 5, difftime);
+ }
req->reply = buf;
req->reply_type = type;
req->replied = 1;
@@ -1411,7 +1413,8 @@ static int sftp_request_send(uint8_t type, struct iovec *iov, size_t count,
pthread_cond_wait(&sshfs.outstanding_cond, &sshfs.lock);
g_hash_table_insert(sshfs.reqtab, GUINT_TO_POINTER(id), req);
- gettimeofday(&req->start, NULL);
+ if (sshfs.debug)
+ gettimeofday(&req->start, NULL);
DEBUG("[%05i] %s\n", id, type_name(type));
pthread_mutex_unlock(&sshfs.lock);
@@ -1934,10 +1937,9 @@ static void sshfs_file_put(struct sshfs_file *sf)
g_free(sf);
}
-static struct sshfs_file *sshfs_file_get(struct sshfs_file *sf)
+static void sshfs_file_get(struct sshfs_file *sf)
{
sf->refs++;
- return sf;
}
static int sshfs_release(const char *path, struct fuse_file_info *fi)
@@ -2155,6 +2157,8 @@ 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;
+
+ sshfs_file_get(sf);
list_add(&req->list, &sf->write_reqs);
}
@@ -2203,7 +2207,7 @@ static int sshfs_write(const char *path, const char *wbuf, size_t size,
if (!sshfs.sync_write && !sf->write_error) {
err = sftp_request_send(SSH_FXP_WRITE, iov, 2,
sshfs_write_begin, sshfs_write_end,
- 0, sshfs_file_get(sf), NULL);
+ 0, sf, NULL);
} else {
err = sftp_request_iov(SSH_FXP_WRITE, iov, 2, SSH_FXP_STATUS,
NULL);
@@ -2498,7 +2502,7 @@ static void usage(const char *progname)
#ifdef SSH_NODELAY_WORKAROUND
" [no]nodelay set nodelay tcp flag in ssh (default: on)\n"
#endif
-" [no]nodelaysrv set nodelay tcp flag in sshd (default: on)\n"
+" [no]nodelaysrv set nodelay tcp flag in sshd (default: off)\n"
" [no]truncate fix truncate for old servers (default: off)\n"
" [no]buflimit fix buffer fillup bug in server (default: on)\n"
" -o idmap=TYPE user/group ID mapping, possible types are:\n"