release() changes
authorMiklos Szeredi <miklos@szeredi.hu>
Tue, 10 Dec 2002 16:09:02 +0000 (16:09 +0000)
committerMiklos Szeredi <miklos@szeredi.hu>
Tue, 10 Dec 2002 16:09:02 +0000 (16:09 +0000)
lib/fuse.c

index fe670d8648d01a121224abc0a6e50841b09cf4f3..49199659d60577a560741a2cdf54960d520fc4c0 100644 (file)
@@ -349,7 +349,7 @@ static int fill_dir(struct fuse_dirhandle *dh, char *name, int type)
     return 0;
 }
 
-static void send_reply_raw(struct fuse *f, char *outbuf, size_t outsize)
+static int send_reply_raw(struct fuse *f, char *outbuf, size_t outsize)
 {
     int res;
 
@@ -370,12 +370,15 @@ static void send_reply_raw(struct fuse *f, char *outbuf, size_t outsize)
         /* ENOENT means the operation was interrupted */
         if(errno != ENOENT)
             perror("fuse: writing device");
+        return -errno;
     }
+    return 0;
 }
 
-static void send_reply(struct fuse *f, struct fuse_in_header *in, int error,
-                       void *arg, size_t argsize)
+static int send_reply(struct fuse *f, struct fuse_in_header *in, int error,
+                      void *arg, size_t argsize)
 {
+    int res;
     char *outbuf;
     size_t outsize;
     struct fuse_out_header *out;
@@ -397,9 +400,10 @@ static void send_reply(struct fuse *f, struct fuse_in_header *in, int error,
     if(argsize != 0)
         memcpy(outbuf + sizeof(struct fuse_out_header), arg, argsize);
 
-    send_reply_raw(f, outbuf, outsize);
-
+    res = send_reply_raw(f, outbuf, outsize);
     free(outbuf);
+
+    return res;
 }
 
 static void do_lookup(struct fuse *f, struct fuse_in_header *in, char *name)
@@ -740,6 +744,7 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
                     struct fuse_open_in *arg)
 {
     int res;
+    int res2;
     char *path;
 
     res = -ENOENT;
@@ -748,9 +753,14 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
         res = -ENOSYS;
         if(f->op.open)
             res = f->op.open(path, arg->flags);
+    }
+    res2 = send_reply(f, in, res, NULL, 0);
+    if(path != NULL) {
+        /* The open syscall was interrupted, so it must be cancelled */
+        if(res == 0 && res2 == -ENOENT && f->op.release)
+            f->op.release(path);
         free(path);
     }
-    send_reply(f, in, res, NULL, 0);
 }
 
 static void do_release(struct fuse *f, struct fuse_in_header *in)