+2005-09-14 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Add memory cleanup on thread exit
+
2005-09-13 Miklos Szeredi <miklos@szeredi.hu>
* Set umask to zero in fusexmp and fusexmp_fh, so that
static int fuse_kern_chan_receive(struct fuse_chan *ch, char *buf, size_t size)
{
ssize_t res = read(fuse_chan_fd(ch), buf, size);
+ int err = errno;
struct fuse_session *se = fuse_chan_session(ch);
assert(se != NULL);
if (res == -1) {
/* EINTR means, the read() was interrupted, ENOENT means the
operation was interrupted */
- if (errno == EINTR || errno == ENOENT)
+ if (err == EINTR || err == ENOENT)
return 0;
/* ENODEV means we got unmounted, so we silenty return failure */
- if (errno != ENODEV)
+ if (err != ENODEV)
perror("fuse: reading device");
return -1;
}
size_t count)
{
ssize_t res = writev(fuse_chan_fd(ch), iov, count);
+ int err = errno;
if (res == -1) {
struct fuse_session *se = fuse_chan_session(ch);
assert(se != NULL);
/* ENOENT means the operation was interrupted */
- if (!fuse_session_exited(se) && errno != ENOENT)
+ if (!fuse_session_exited(se) && err != ENOENT)
perror("fuse: writing device");
- return -errno;
+ return -err;
}
return 0;
}
return NULL;
}
+ pthread_cleanup_push(free, buf);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
pthread_mutex_unlock(&w->lock);
fuse_session_process(w->se, buf, res, w->ch);
}
+ pthread_cleanup_pop(1);
/* Wait for cancellation */
if (!is_mainthread)