xfs
[Top] [All Lists]

[xfstests PATCH 2/4] locktest: set f_fd to INVALID_HANDLE on close

To: xfs@xxxxxxxxxxx
Subject: [xfstests PATCH 2/4] locktest: set f_fd to INVALID_HANDLE on close
From: Jeff Layton <jlayton@xxxxxxxxxxxxxxx>
Date: Mon, 12 May 2014 11:06:31 -0400
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1399907193-23857-1-git-send-email-jlayton@xxxxxxxxxxxxxxx>
References: <1399907193-23857-1-git-send-email-jlayton@xxxxxxxxxxxxxxx>
Ensure that the fd is marked invalid after close. Also, the "closed"
and "reopen" variables are always set to 0. Remove them.

Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxxxxxxx>
---
 src/locktest.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/locktest.c b/src/locktest.c
index b440a43e3947..0a674a7ff5c2 100644
--- a/src/locktest.c
+++ b/src/locktest.c
@@ -96,8 +96,6 @@ static int    debug = 0;
 static int     server = 1;
 static int     maxio = 8192;
 static int     port = 7890;
-static int     reopen=0;
-static int     closed=0;
 static int     testnumber = -1;
 static int     saved_errno = 0;
 
@@ -615,13 +613,10 @@ int do_open(int flag)
 {
     if ((f_fd = OPEN(filename, flag)) == INVALID_HANDLE) {
        perror("shared file create");
-       closed = 0;
        return FAIL;
        /*NOTREACHED*/
     }
 
-    closed = 0;
-
 #ifdef __sun
     if (D_flag) {
         directio(f_fd, DIRECTIO_ON);
@@ -701,12 +696,13 @@ int do_close(void)
 
     errno =0;
     CLOSE(f_fd);
+    f_fd = INVALID_HANDLE;
 
     saved_errno = errno;           
        
     if (errno)
        return FAIL;
-    return(PASS);
+    return PASS;
 }
 
 void
@@ -778,7 +774,7 @@ void recv_ctl(void)
 void
 cleanup(void)
 {
-    if (f_fd>=0 && !reopen && !closed)
+    if (f_fd>=0)
         CLOSE(f_fd);
     
     if (c_fd>=0)
-- 
1.9.0

<Prev in Thread] Current Thread [Next in Thread>