@@ -34,30 +34,34 @@ static int fault;
34
34
35
35
static int fpm_children_make (struct fpm_worker_pool_s * wp , int in_event_loop );
36
36
37
- static void fpm_children_cleanup (int which , void * arg )
37
+ static void fpm_children_cleanup (int which , void * arg ) /* {{{ */
38
38
{
39
39
free (last_faults );
40
40
}
41
+ /* }}} */
41
42
42
- static struct fpm_child_s * fpm_child_alloc ()
43
+ static struct fpm_child_s * fpm_child_alloc () /* {{{ */
43
44
{
44
45
struct fpm_child_s * ret ;
45
46
46
47
ret = malloc (sizeof (struct fpm_child_s ));
47
48
48
- if (!ret ) return 0 ;
49
+ if (!ret ) {
50
+ return 0 ;
51
+ }
49
52
50
53
memset (ret , 0 , sizeof (* ret ));
51
-
52
54
return ret ;
53
55
}
56
+ /* }}} */
54
57
55
- static void fpm_child_free (struct fpm_child_s * child )
58
+ static void fpm_child_free (struct fpm_child_s * child ) /* {{{ */
56
59
{
57
60
free (child );
58
61
}
62
+ /* }}} */
59
63
60
- static void fpm_child_close (struct fpm_child_s * child , int in_event_loop )
64
+ static void fpm_child_close (struct fpm_child_s * child , int in_event_loop ) /* {{{ */
61
65
{
62
66
if (child -> fd_stdout != -1 ) {
63
67
if (in_event_loop ) {
@@ -79,32 +83,42 @@ static void fpm_child_close(struct fpm_child_s *child, int in_event_loop)
79
83
80
84
fpm_child_free (child );
81
85
}
86
+ /* }}} */
82
87
83
- static void fpm_child_link (struct fpm_child_s * child )
88
+ static void fpm_child_link (struct fpm_child_s * child ) /* {{{ */
84
89
{
85
90
struct fpm_worker_pool_s * wp = child -> wp ;
86
91
87
92
++ wp -> running_children ;
88
93
++ fpm_globals .running_children ;
89
94
90
95
child -> next = wp -> children ;
91
- if (child -> next ) child -> next -> prev = child ;
96
+ if (child -> next ) {
97
+ child -> next -> prev = child ;
98
+ }
92
99
child -> prev = 0 ;
93
100
wp -> children = child ;
94
101
}
102
+ /* }}} */
95
103
96
- static void fpm_child_unlink (struct fpm_child_s * child )
104
+ static void fpm_child_unlink (struct fpm_child_s * child ) /* {{{ */
97
105
{
98
106
-- child -> wp -> running_children ;
99
107
-- fpm_globals .running_children ;
100
108
101
- if (child -> prev ) child -> prev -> next = child -> next ;
102
- else child -> wp -> children = child -> next ;
103
- if (child -> next ) child -> next -> prev = child -> prev ;
109
+ if (child -> prev ) {
110
+ child -> prev -> next = child -> next ;
111
+ } else {
112
+ child -> wp -> children = child -> next ;
113
+ }
104
114
115
+ if (child -> next ) {
116
+ child -> next -> prev = child -> prev ;
117
+ }
105
118
}
119
+ /* }}} */
106
120
107
- static struct fpm_child_s * fpm_child_find (pid_t pid )
121
+ static struct fpm_child_s * fpm_child_find (pid_t pid ) /* {{{ */
108
122
{
109
123
struct fpm_worker_pool_s * wp ;
110
124
struct fpm_child_s * child = 0 ;
@@ -126,8 +140,9 @@ static struct fpm_child_s *fpm_child_find(pid_t pid)
126
140
127
141
return child ;
128
142
}
143
+ /* }}} */
129
144
130
- static void fpm_child_init (struct fpm_worker_pool_s * wp )
145
+ static void fpm_child_init (struct fpm_worker_pool_s * wp ) /* {{{ */
131
146
{
132
147
fpm_globals .max_requests = wp -> config -> max_requests ;
133
148
@@ -141,8 +156,9 @@ static void fpm_child_init(struct fpm_worker_pool_s *wp)
141
156
exit (255 );
142
157
}
143
158
}
159
+ /* }}} */
144
160
145
- int fpm_children_free (struct fpm_child_s * child )
161
+ int fpm_children_free (struct fpm_child_s * child ) /* {{{ */
146
162
{
147
163
struct fpm_child_s * next ;
148
164
@@ -153,8 +169,9 @@ int fpm_children_free(struct fpm_child_s *child)
153
169
154
170
return 0 ;
155
171
}
172
+ /* }}} */
156
173
157
- void fpm_children_bury ()
174
+ void fpm_children_bury () /* {{{ */
158
175
{
159
176
int status ;
160
177
pid_t pid ;
@@ -174,8 +191,7 @@ void fpm_children_bury()
174
191
severity = ZLOG_WARNING ;
175
192
}
176
193
177
- }
178
- else if (WIFSIGNALED (status )) {
194
+ } else if (WIFSIGNALED (status )) {
179
195
const char * signame = fpm_signal_names [WTERMSIG (status )];
180
196
const char * have_core = WCOREDUMP (status ) ? " (core dumped)" : "" ;
181
197
@@ -188,8 +204,7 @@ void fpm_children_bury()
188
204
if (WTERMSIG (status ) != SIGQUIT ) { /* possible request loss */
189
205
severity = ZLOG_WARNING ;
190
206
}
191
- }
192
- else if (WIFSTOPPED (status )) {
207
+ } else if (WIFSTOPPED (status )) {
193
208
194
209
zlog (ZLOG_STUFF , ZLOG_NOTICE , "child %d stopped for tracing" , (int ) pid );
195
210
@@ -251,15 +266,14 @@ void fpm_children_bury()
251
266
if (fpm_globals .is_child ) {
252
267
break ;
253
268
}
254
- }
255
- else {
269
+ } else {
256
270
zlog (ZLOG_STUFF , ZLOG_ALERT , "oops, unknown child exited %s" , buf );
257
271
}
258
272
}
259
-
260
273
}
274
+ /* }}} */
261
275
262
- static struct fpm_child_s * fpm_resources_prepare (struct fpm_worker_pool_s * wp )
276
+ static struct fpm_child_s * fpm_resources_prepare (struct fpm_worker_pool_s * wp ) /* {{{ */
263
277
{
264
278
struct fpm_child_s * c ;
265
279
@@ -286,29 +300,33 @@ static struct fpm_child_s *fpm_resources_prepare(struct fpm_worker_pool_s *wp)
286
300
287
301
return c ;
288
302
}
303
+ /* }}} */
289
304
290
- static void fpm_resources_discard (struct fpm_child_s * child )
305
+ static void fpm_resources_discard (struct fpm_child_s * child ) /* {{{ */
291
306
{
292
307
fpm_shm_slots_discard_slot (child );
293
308
fpm_stdio_discard_pipes (child );
294
309
fpm_child_free (child );
295
310
}
311
+ /* }}} */
296
312
297
- static void fpm_child_resources_use (struct fpm_child_s * child )
313
+ static void fpm_child_resources_use (struct fpm_child_s * child ) /* {{{ */
298
314
{
299
315
fpm_shm_slots_child_use_slot (child );
300
316
fpm_stdio_child_use_pipes (child );
301
317
fpm_child_free (child );
302
318
}
319
+ /* }}} */
303
320
304
- static void fpm_parent_resources_use (struct fpm_child_s * child )
321
+ static void fpm_parent_resources_use (struct fpm_child_s * child ) /* {{{ */
305
322
{
306
323
fpm_shm_slots_parent_use_slot (child );
307
324
fpm_stdio_parent_use_pipes (child );
308
325
fpm_child_link (child );
309
326
}
327
+ /* }}} */
310
328
311
- static int fpm_children_make (struct fpm_worker_pool_s * wp , int in_event_loop )
329
+ static int fpm_children_make (struct fpm_worker_pool_s * wp , int in_event_loop ) /* {{{ */
312
330
{
313
331
int enough = 0 ;
314
332
pid_t pid ;
@@ -356,13 +374,15 @@ static int fpm_children_make(struct fpm_worker_pool_s *wp, int in_event_loop)
356
374
357
375
return 1 ; /* we are done */
358
376
}
377
+ /* }}} */
359
378
360
- int fpm_children_create_initial (struct fpm_worker_pool_s * wp )
379
+ int fpm_children_create_initial (struct fpm_worker_pool_s * wp ) /* {{{ */
361
380
{
362
381
return fpm_children_make (wp , 0 /* not in event loop yet */ );
363
382
}
383
+ /* }}} */
364
384
365
- int fpm_children_init_main ()
385
+ int fpm_children_init_main () /* {{{ */
366
386
{
367
387
if (fpm_global_config .emergency_restart_threshold &&
368
388
fpm_global_config .emergency_restart_interval ) {
@@ -382,4 +402,5 @@ int fpm_children_init_main()
382
402
383
403
return 0 ;
384
404
}
405
+ /* }}} */
385
406
0 commit comments