walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
c6aa18e
commit bc870150cc2116584aee288d15ac2b9a2f825ff5
c6aa18e
Author: Steve Dickson <steved@redhat.com>
c6aa18e
Date:   Wed Dec 17 16:41:35 2008 -0500
c6aa18e
c6aa18e
    statd: not unlinking host files
c6aa18e
    
c6aa18e
    Statd is not unlinking host files during SM_UNMON and
c6aa18e
    SM_UNMON_ALL calls because the given host is still on the run-time
c6aa18e
    notify list (rtnl) and the check flag is set when xunlink() is
c6aa18e
    called. But the next thing the caller of xunlink() does is
c6aa18e
    remove the host from the rtnl list which means the
c6aa18e
    unlink will never happen.
c6aa18e
    
c6aa18e
    So this patch removes the check flag from xunlink() since
c6aa18e
    its not needed and correctly allocates and frees memory
c6aa18e
    used by xunlink().
c6aa18e
    
c6aa18e
    Signed-off-by: Steve Dickson <steved@redhat.com>
c6aa18e
c6aa18e
diff --git a/utils/statd/misc.c b/utils/statd/misc.c
c6aa18e
index fd201b4..7256291 100644
c6aa18e
--- a/utils/statd/misc.c
c6aa18e
+++ b/utils/statd/misc.c
c6aa18e
@@ -53,23 +53,25 @@ xstrdup (const char *string)
c6aa18e
 
c6aa18e
 
c6aa18e
 /*
c6aa18e
- * Call with check=1 to verify that this host is not still on the rtnl
c6aa18e
- * before unlinking file.
c6aa18e
+ * Unlinking a file.
c6aa18e
  */
c6aa18e
 void
c6aa18e
-xunlink (char *path, char *host, short int check)
c6aa18e
+xunlink (char *path, char *host)
c6aa18e
 {
c6aa18e
-  char *tozap;
c6aa18e
+	char *tozap;
c6aa18e
 
c6aa18e
-  tozap=alloca (strlen(path)+strlen(host)+2);
c6aa18e
-  sprintf (tozap, "%s/%s", path, host);
c6aa18e
+	tozap = malloc(strlen(path)+strlen(host)+2);
c6aa18e
+	if (tozap == NULL) {
c6aa18e
+		note(N_ERROR, "xunlink: malloc failed: errno %d (%s)", 
c6aa18e
+			errno, strerror(errno));
c6aa18e
+		return;
c6aa18e
+	}
c6aa18e
+	sprintf (tozap, "%s/%s", path, host);
c6aa18e
 
c6aa18e
-  if (!check || !nlist_gethost(rtnl, host, 0)) {
c6aa18e
-    if (unlink (tozap) == -1)
c6aa18e
-      note (N_ERROR, "unlink (%s): %s", tozap, strerror (errno));
c6aa18e
-    else
c6aa18e
-      dprintf (N_DEBUG, "Unlinked %s", tozap);
c6aa18e
-  }
c6aa18e
-  else
c6aa18e
-    dprintf (N_DEBUG, "Not unlinking %s--host still monitored.", tozap);
c6aa18e
+	if (unlink (tozap) == -1)
c6aa18e
+		note(N_ERROR, "unlink (%s): %s", tozap, strerror (errno));
c6aa18e
+	else
c6aa18e
+		dprintf (N_DEBUG, "Unlinked %s", tozap);
c6aa18e
+
c6aa18e
+	free(tozap);
c6aa18e
 }
c6aa18e
diff --git a/utils/statd/monitor.c b/utils/statd/monitor.c
c6aa18e
index a6a1d9c..24c2531 100644
c6aa18e
--- a/utils/statd/monitor.c
c6aa18e
+++ b/utils/statd/monitor.c
c6aa18e
@@ -352,7 +352,7 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp)
c6aa18e
 			/* PRC: do the HA callout: */
c6aa18e
 			ha_callout("del-client", mon_name, my_name, -1);
c6aa18e
 
c6aa18e
-			xunlink(SM_DIR, clnt->dns_name, 1);
c6aa18e
+			xunlink(SM_DIR, clnt->dns_name);
c6aa18e
 			nlist_free(&rtnl, clnt);
c6aa18e
 
c6aa18e
 			return (&result);
c6aa18e
@@ -404,7 +404,7 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp)
c6aa18e
 			temp = NL_NEXT(clnt);
c6aa18e
 			/* PRC: do the HA callout: */
c6aa18e
 			ha_callout("del-client", mon_name, my_name, -1);
c6aa18e
-			xunlink(SM_DIR, clnt->dns_name, 1);
c6aa18e
+			xunlink(SM_DIR, clnt->dns_name);
c6aa18e
 			nlist_free(&rtnl, clnt);
c6aa18e
 			++count;
c6aa18e
 			clnt = temp;
c6aa18e
diff --git a/utils/statd/statd.h b/utils/statd/statd.h
c6aa18e
index 5a6e289..88ba208 100644
c6aa18e
--- a/utils/statd/statd.h
c6aa18e
+++ b/utils/statd/statd.h
c6aa18e
@@ -53,7 +53,7 @@ extern int	process_notify_list(void);
c6aa18e
 extern int	process_reply(FD_SET_TYPE *);
c6aa18e
 extern char *	xstrdup(const char *);
c6aa18e
 extern void *	xmalloc(size_t);
c6aa18e
-extern void	xunlink (char *, char *, short int);
c6aa18e
+extern void	xunlink (char *, char *);
c6aa18e
 extern void	load_state(void);
c6aa18e
 
c6aa18e
 /*