]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/statd/monitor.c
nfs-utils: Provide type-checked version of svc_getcaller()
[nfs-utils.git] / utils / statd / monitor.c
index d300338503d92a1668ff32f7de3bc9214461794f..169cd78ac82b17a99c5ce90850bb97f4d4fac901 100644 (file)
@@ -20,6 +20,8 @@
 #include <errno.h>
 #include <arpa/inet.h>
 #include <dirent.h>
+
+#include "rpcmisc.h"
 #include "misc.h"
 #include "statd.h"
 #include "notlist.h"
@@ -36,9 +38,10 @@ notify_list *                rtnl = NULL;    /* Run-time notify list. */
 static int
 caller_is_localhost(struct svc_req *rqstp)
 {
+       struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt);
        struct in_addr  caller;
 
-       caller = svc_getcaller(rqstp->rq_xprt)->sin_addr;
+       caller = sin->sin_addr;
        if (caller.s_addr != htonl(INADDR_LOOPBACK)) {
                note(N_WARNING,
                        "Call to statd from non-local host %s",
@@ -326,12 +329,13 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp)
 
 
        /* Check if we're monitoring anyone. */
-       if (!(clnt = rtnl)) {
+       if (rtnl == NULL) {
                note(N_WARNING,
                        "Received SM_UNMON request from %s for %s while not "
                        "monitoring any hosts.", my_name, argp->mon_name);
                return (&result);
        }
+       clnt = rtnl;
 
        /*
         * OK, we are.  Now look for appropriate entry in run-time list.
@@ -351,7 +355,7 @@ sm_unmon_1_svc(struct mon_id *argp, struct svc_req *rqstp)
                        /* PRC: do the HA callout: */
                        ha_callout("del-client", mon_name, my_name, -1);
 
-                       xunlink(SM_DIR, clnt->dns_name, 1);
+                       xunlink(SM_DIR, clnt->dns_name);
                        nlist_free(&rtnl, clnt);
 
                        return (&result);
@@ -379,11 +383,12 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp)
 
        result.state = MY_STATE;
 
-       if (!(clnt = rtnl)) {
+       if (rtnl == NULL) {
                note(N_WARNING, "Received SM_UNMON_ALL request from %s "
                        "while not monitoring any hosts", my_name);
                return (&result);
        }
+       clnt = rtnl;
 
        while ((clnt = nlist_gethost(clnt, my_name, 1))) {
                if (NL_MY_PROC(clnt) == argp->my_proc &&
@@ -402,7 +407,7 @@ sm_unmon_all_1_svc(struct my_id *argp, struct svc_req *rqstp)
                        temp = NL_NEXT(clnt);
                        /* PRC: do the HA callout: */
                        ha_callout("del-client", mon_name, my_name, -1);
-                       xunlink(SM_DIR, clnt->dns_name, 1);
+                       xunlink(SM_DIR, clnt->dns_name);
                        nlist_free(&rtnl, clnt);
                        ++count;
                        clnt = temp;