@@ -95,6 +95,16 @@ modstack_init(struct module_stack* stack)
95
95
stack -> mod = NULL ;
96
96
}
97
97
98
+ void
99
+ modstack_free (struct module_stack * stack )
100
+ {
101
+ if (!stack )
102
+ return ;
103
+ stack -> num = 0 ;
104
+ free (stack -> mod );
105
+ stack -> mod = NULL ;
106
+ }
107
+
98
108
int
99
109
modstack_config (struct module_stack * stack , const char * module_conf )
100
110
{
@@ -223,7 +233,7 @@ module_func_block* module_factory(const char** str)
223
233
}
224
234
225
235
int
226
- modstack_startup (struct module_stack * stack , const char * module_conf ,
236
+ modstack_call_startup (struct module_stack * stack , const char * module_conf ,
227
237
struct module_env * env )
228
238
{
229
239
int i ;
@@ -249,22 +259,33 @@ modstack_startup(struct module_stack* stack, const char* module_conf,
249
259
}
250
260
251
261
int
252
- modstack_setup (struct module_stack * stack , const char * module_conf ,
262
+ modstack_call_init (struct module_stack * stack , const char * module_conf ,
253
263
struct module_env * env )
254
264
{
255
- int i ;
256
- if (stack -> num != 0 )
257
- modstack_desetup (stack , env );
265
+ int i , changed = 0 ;
258
266
env -> need_to_validate = 0 ; /* set by module init below */
259
267
for (i = 0 ; i < stack -> num ; i ++ ) {
260
268
while (* module_conf && isspace (* module_conf ))
261
269
module_conf ++ ;
262
270
if (strncmp (stack -> mod [i ]-> name , module_conf ,
263
271
strlen (stack -> mod [i ]-> name ))) {
264
- log_err ("changed module ordering during reload not supported" );
265
- return 0 ;
272
+ if (stack -> mod [i ]-> startup || stack -> mod [i ]-> destartup ) {
273
+ log_err ("changed module ordering during reload not supported, for module that needs startup" );
274
+ return 0 ;
275
+ } else {
276
+ changed = 1 ;
277
+ }
266
278
}
267
279
module_conf += strlen (stack -> mod [i ]-> name );
280
+ }
281
+ if (changed ) {
282
+ modstack_free (stack );
283
+ if (!modstack_config (stack , module_conf )) {
284
+ return 0 ;
285
+ }
286
+ }
287
+
288
+ for (i = 0 ; i < stack -> num ; i ++ ) {
268
289
verbose (VERB_OPS , "init module %d: %s" ,
269
290
i , stack -> mod [i ]-> name );
270
291
fptr_ok (fptr_whitelist_mod_init (stack -> mod [i ]-> init ));
@@ -278,7 +299,7 @@ modstack_setup(struct module_stack* stack, const char* module_conf,
278
299
}
279
300
280
301
void
281
- modstack_desetup (struct module_stack * stack , struct module_env * env )
302
+ modstack_call_deinit (struct module_stack * stack , struct module_env * env )
282
303
{
283
304
int i ;
284
305
for (i = 0 ; i < stack -> num ; i ++ ) {
@@ -288,7 +309,7 @@ modstack_desetup(struct module_stack* stack, struct module_env* env)
288
309
}
289
310
290
311
void
291
- modstack_destartup (struct module_stack * stack , struct module_env * env )
312
+ modstack_call_destartup (struct module_stack * stack , struct module_env * env )
292
313
{
293
314
int i ;
294
315
for (i = 0 ; i < stack -> num ; i ++ ) {
@@ -297,9 +318,6 @@ modstack_destartup(struct module_stack* stack, struct module_env* env)
297
318
fptr_ok (fptr_whitelist_mod_destartup (stack -> mod [i ]-> destartup ));
298
319
(* stack -> mod [i ]-> destartup )(env , i );
299
320
}
300
- stack -> num = 0 ;
301
- free (stack -> mod );
302
- stack -> mod = NULL ;
303
321
}
304
322
305
323
int
0 commit comments