This source file includes following definitions.
- rf_FreeShutdownEnt
- _rf_ShutdownCreate
- rf_ShutdownList
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 #include "rf_types.h"
39 #include "rf_threadstuff.h"
40 #include "rf_shutdown.h"
41 #include "rf_debugMem.h"
42 #include "rf_freelist.h"
43
44 void rf_FreeShutdownEnt(RF_ShutdownList_t *);
45 void
46 rf_FreeShutdownEnt(RF_ShutdownList_t *ent)
47 {
48 FREE(ent, M_RAIDFRAME);
49 }
50
51 int
52 _rf_ShutdownCreate(RF_ShutdownList_t **listp, void (*cleanup) (void *arg),
53 void *arg, char *file, int line)
54 {
55 RF_ShutdownList_t *ent;
56
57
58
59
60
61
62
63 ent = (RF_ShutdownList_t *) malloc(sizeof(RF_ShutdownList_t),
64 M_RAIDFRAME, M_NOWAIT);
65 if (ent == NULL)
66 return (ENOMEM);
67 ent->cleanup = cleanup;
68 ent->arg = arg;
69 ent->file = file;
70 ent->line = line;
71 ent->next = *listp;
72 *listp = ent;
73 return (0);
74 }
75
76 int
77 rf_ShutdownList(RF_ShutdownList_t **list)
78 {
79 RF_ShutdownList_t *r, *next;
80 char *file;
81 int line;
82
83 for (r = *list; r; r = next) {
84 next = r->next;
85 file = r->file;
86 line = r->line;
87
88 if (rf_shutdownDebug) {
89 printf("call shutdown, created %s:%d\n", file, line);
90 }
91 r->cleanup(r->arg);
92
93 if (rf_shutdownDebug) {
94 printf("completed shutdown, created %s:%d\n", file,
95 line);
96 }
97 rf_FreeShutdownEnt(r);
98 }
99 *list = NULL;
100 return (0);
101 }