walters / rpms / nfs-utils

Forked from rpms/nfs-utils 6 years ago
Clone
70f8963
diff -up nfs-utils-1.1.4/utils/statd/sm-notify.c.orig nfs-utils-1.1.4/utils/statd/sm-notify.c
70f8963
--- nfs-utils-1.1.4/utils/statd/sm-notify.c.orig	2008-12-17 15:09:13.000000000 -0500
70f8963
+++ nfs-utils-1.1.4/utils/statd/sm-notify.c	2008-12-17 15:11:07.000000000 -0500
70f8963
@@ -133,6 +133,17 @@ static struct addrinfo *smn_lookup(const
70f8963
 	return ai;
70f8963
 }
70f8963
 
70f8963
+static void smn_forget_host(struct nsm_host *host)
70f8963
+{
70f8963
+	unlink(host->path);
70f8963
+	free(host->path);
70f8963
+	free(host->name);
70f8963
+	if (host->ai)
70f8963
+		freeaddrinfo(host->ai);
70f8963
+
70f8963
+	free(host);
70f8963
+}
70f8963
+
70f8963
 int
70f8963
 main(int argc, char **argv)
70f8963
 {
70f8963
@@ -342,13 +353,8 @@ notify(void)
70f8963
 			hp = hosts;
70f8963
 			hosts = hp->next;
70f8963
 
70f8963
-			if (notify_host(sock, hp)){
70f8963
-				unlink(hp->path);
70f8963
-				free(hp->name);
70f8963
-				free(hp->path);
70f8963
-				free(hp);
70f8963
+			if (notify_host(sock, hp))
70f8963
 				continue;
70f8963
-			}
70f8963
 
70f8963
 			/* Set the timeout for this call, using an
70f8963
 			   exponential timeout strategy */
70f8963
@@ -403,6 +409,7 @@ notify_host(int sock, struct nsm_host *h
70f8963
 			nsm_log(LOG_WARNING,
70f8963
 				"%s doesn't seem to be a valid address,"
70f8963
 				" skipped", host->name);
70f8963
+			smn_forget_host(host);
70f8963
 			return 1;
70f8963
 		}
70f8963
 	}
70f8963
@@ -547,11 +554,7 @@ recv_reply(int sock)
70f8963
 		if (p <= end) {
70f8963
 			nsm_log(LOG_DEBUG, "Host %s notified successfully",
70f8963
 					hp->name);
70f8963
-			unlink(hp->path);
70f8963
-			free(hp->name);
70f8963
-			free(hp->path);
70f8963
-			free(hp);
70f8963
-			freeaddrinfo(hp->ai);
70f8963
+			smn_forget_host(hp);
70f8963
 			return;
70f8963
 		}
70f8963
 	}