]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/statd/callback.c
Initial revision
[nfs-utils.git] / utils / statd / callback.c
1 /*
2  * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff
3  * Modified by Olaf Kirch, Oct. 1996.
4  *
5  * NSM for Linux.
6  */
7
8 #include "config.h"
9 #include "statd.h"
10 #include "notlist.h"
11
12 /* Callback notify list. */
13 notify_list *cbnl = NULL;
14
15
16 /* 
17  * Services SM_NOTIFY requests.
18  * Any clients that have asked us to monitor that host are put on
19  * the global callback list, which is processed as soon as statd
20  * returns to svc_run.
21  */
22 void *
23 sm_notify_1_svc(struct stat_chge *argp, struct svc_req *rqstp)
24 {
25         notify_list    *lp, *call;
26         static char    *result = NULL;
27
28         dprintf(L_DEBUG, "Received SM_NOTIFY from %s, state: %d",
29                                 argp->mon_name, argp->state);
30
31         if ((lp = rtnl) != NULL) {
32                 log(L_WARNING, "SM_NOTIFY from %s--nobody looking!",
33                                 argp->mon_name, argp->state);
34                 return ((void *) &result);
35         }
36
37         /* okir change: statd doesn't remove the remote host from its
38          * internal monitor list when receiving an SM_NOTIFY call from
39          * it. Lockd will want to continue monitoring the remote host
40          * until it issues an SM_UNMON call.
41          */
42         while ((lp = nlist_gethost(lp, argp->mon_name, 0)) != NULL) {
43                 if (NL_STATE(lp) != argp->state) {
44                         NL_STATE(lp) = argp->state;
45                         call = nlist_clone(lp);
46                         NL_TYPE(call) = NOTIFY_CALLBACK;
47                         nlist_insert(&notify, call);
48                 }
49                 lp = NL_NEXT(lp);
50         }
51
52         return ((void *) &result);
53 }