summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@redhat.com>2014-01-31 15:11:37 -0600
committerVijay Bellur <vbellur@redhat.com>2014-02-05 22:26:07 -0800
commite3162ed7e91510185316eae36f5c2c25bde53a68 (patch)
tree8c002b5b656f7ac9fe81b4d4eae3e902870ce3b6 /libglusterfs
parente021078220c30e781ef016b42f8cee8229042bb1 (diff)
libglusterfs: Allow all valid file handle values to be closed.
Zero (0) is a valid file handle. The code, as written, interprets return values of open(2) that are less than or equal to zero to indicate an error. Only -1 indicates an error. BUG: 789278 CID: 1124756 Change-Id: Ie77c25f1f557d5d5adcec464b49dc7df2e3dc7e5 Signed-off-by: Christopher R. Hertel <crh@redhat.com> Reviewed-on: http://review.gluster.org/6884 Reviewed-by: Lalatendu Mohanty <lmohanty@redhat.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/store.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index 5af2359..66a5906 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -362,12 +362,11 @@ gf_store_handle_new (char *path, gf_store_handle_t **handle)
goto out;
spath = gf_strdup (path);
-
if (!spath)
goto out;
fd = open (path, O_RDWR | O_CREAT | O_APPEND, 0600);
- if (fd <= 0) {
+ if (fd < 0) {
gf_log ("", GF_LOG_ERROR, "Failed to open file: %s, error: %s",
path, strerror (errno));
goto out;
@@ -383,7 +382,7 @@ gf_store_handle_new (char *path, gf_store_handle_t **handle)
ret = 0;
out:
- if (fd > 0)
+ if (fd >= 0)
close (fd);
if (ret == -1) {