diff mbox

[3/4] rpc.gssd: handle error to open toplevel directory

Message ID 1343768449-32205-3-git-send-email-bfields@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bruce Fields July 31, 2012, 9 p.m. UTC
From: "J. Bruce Fields" <bfields@redhat.com>

Reverse the sense of the test here, and also add debugging and cleanup
in the error case.

(Though the lack of cleanup isn't currently a problem in practice since
we'll eventually exit in this case.)

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 utils/gssd/gssd_main_loop.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Steve Dickson Aug. 6, 2012, 2:23 p.m. UTC | #1
On 07/31/2012 05:00 PM, J. Bruce Fields wrote:
> From: "J. Bruce Fields" <bfields@redhat.com>
> 
> Reverse the sense of the test here, and also add debugging and cleanup
> in the error case.
> 
> (Though the lack of cleanup isn't currently a problem in practice since
> we'll eventually exit in this case.)
> 
> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Committed...

steved.

> ---
>  utils/gssd/gssd_main_loop.c |   10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c
> index 6914687..142c8c5 100644
> --- a/utils/gssd/gssd_main_loop.c
> +++ b/utils/gssd/gssd_main_loop.c
> @@ -121,11 +121,13 @@ topdirs_add_entry(struct dirent *dent)
>  	}
>  	snprintf(tdi->dirname, PATH_MAX, "%s/%s", pipefs_dir, dent->d_name);
>  	tdi->fd = open(tdi->dirname, O_RDONLY);
> -	if (tdi->fd != -1) {
> -		fcntl(tdi->fd, F_SETSIG, DNOTIFY_SIGNAL);
> -		fcntl(tdi->fd, F_NOTIFY,
> -		      DN_CREATE|DN_DELETE|DN_MODIFY|DN_MULTISHOT);
> +	if (tdi->fd == -1) {
> +		printerr(0, "ERROR: failed to open %s\n", tdi->dirname);
> +		free(tdi);
> +		return -1;
>  	}
> +	fcntl(tdi->fd, F_SETSIG, DNOTIFY_SIGNAL);
> +	fcntl(tdi->fd, F_NOTIFY, DN_CREATE|DN_DELETE|DN_MODIFY|DN_MULTISHOT);
>  
>  	TAILQ_INSERT_HEAD(&topdirs_list, tdi, list);
>  	return 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c
index 6914687..142c8c5 100644
--- a/utils/gssd/gssd_main_loop.c
+++ b/utils/gssd/gssd_main_loop.c
@@ -121,11 +121,13 @@  topdirs_add_entry(struct dirent *dent)
 	}
 	snprintf(tdi->dirname, PATH_MAX, "%s/%s", pipefs_dir, dent->d_name);
 	tdi->fd = open(tdi->dirname, O_RDONLY);
-	if (tdi->fd != -1) {
-		fcntl(tdi->fd, F_SETSIG, DNOTIFY_SIGNAL);
-		fcntl(tdi->fd, F_NOTIFY,
-		      DN_CREATE|DN_DELETE|DN_MODIFY|DN_MULTISHOT);
+	if (tdi->fd == -1) {
+		printerr(0, "ERROR: failed to open %s\n", tdi->dirname);
+		free(tdi);
+		return -1;
 	}
+	fcntl(tdi->fd, F_SETSIG, DNOTIFY_SIGNAL);
+	fcntl(tdi->fd, F_NOTIFY, DN_CREATE|DN_DELETE|DN_MODIFY|DN_MULTISHOT);
 
 	TAILQ_INSERT_HEAD(&topdirs_list, tdi, list);
 	return 0;