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>
This commit is contained in:
Christopher R. Hertel 2014-01-31 15:11:37 -06:00 committed by Vijay Bellur
parent e021078220
commit e3162ed7e9

View File

@ -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) {