aboutsummaryrefslogtreecommitdiff
path: root/src/comp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c65
1 files changed, 30 insertions, 35 deletions
<
diff --git a/src/comp.c b/src/comp.c
index fcd0a14..c3e998a 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -1,5 +1,5 @@
1/* This file is part of GNU Pies. 1/* This file is part of GNU Pies.
2 Copyright (C) 2016-2017 Sergey Poznyakoff 2 Copyright (C) 2016-2019 Sergey Poznyakoff
3 3
4 GNU Pies is free software; you can redistribute it and/or modify 4 GNU Pies is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ component_link (struct component *comp, struct component *ref)
50 if (!ref) 50 if (!ref)
51 { 51 {
52 struct complist *list = &comp_list[comp->listidx]; 52 struct complist *list = &comp_list[comp->listidx];
53 53
54 comp->prev = NULL; 54 comp->prev = NULL;
55 comp->next = list->head; 55 comp->next = list->head;
56 if (list->head) 56 if (list->head)
@@ -68,7 +68,7 @@ component_link (struct component *comp, struct component *ref)
68 68
69 comp->prev = ref; 69 comp->prev = ref;
70 comp->next = ref->next; 70 comp->next = ref->next;
71 71
72 if ((x = ref->next)) 72 if ((x = ref->next))
73 x->prev = comp; 73 x->prev = comp;
74 else 74 else
@@ -89,7 +89,7 @@ component_unlink (struct component *comp)
89{ 89{
90 struct complist *list = &comp_list[comp->listidx]; 90 struct complist *list = &comp_list[comp->listidx];
91 struct component *x; 91 struct component *x;
92 92
93 if ((x = comp->prev)) 93 if ((x = comp->prev))
94 x->next = comp->next; 94 x->next = comp->next;
95 else 95 else
@@ -98,7 +98,7 @@ component_unlink (struct component *comp)
98 x->prev = comp->prev; 98 x->prev = comp->prev;
99 else 99 else
100 list->tail = comp->prev; 100 list->tail = comp->prev;
101} 101}
102 102
103int 103int
104component_list_is_empty (void) 104component_list_is_empty (void)
@@ -129,7 +129,7 @@ component_lookup_index (const char *tag)
129 return i; 129 return i;
130 return -1; 130 return -1;
131} 131}
132 132
133struct component * 133struct component *
134component_create (const char *name) 134component_create (const char *name)
135{ 135{
@@ -208,10 +208,10 @@ static int
208argvcmp (char **a, char **b) 208argvcmp (char **a, char **b)
209{ 209{
210 size_t i; 210 size_t i;
211 211
212 if (!a != !b) 212 if (!a != !b)
213 return 1; 213 return 1;
214 214
215 for (i = 0; a[i]; i++) 215 for (i = 0; a[i]; i++)
216 if (!b[i] || strcmp (b[i], a[i])) 216 if (!b[i] || strcmp (b[i], a[i]))
217 return 1; 217 return 1;
@@ -250,7 +250,7 @@ redirector_cmp (struct redirector const *a, struct redirector const *b)
250 250
251 return 0; 251 return 0;
252} 252}
253 253
254static int 254static int
255component_match (struct component *comp, struct component *ref) 255component_match (struct component *comp, struct component *ref)
256{ 256{
@@ -258,7 +258,7 @@ component_match (struct component *comp, struct component *ref)
258#define EQ(memb) MATCH (comp->memb != ref->memb) 258#define EQ(memb) MATCH (comp->memb != ref->memb)
259#define FN(memb,fun) MATCH (fun (comp->memb, ref->memb)) 259#define FN(memb,fun) MATCH (fun (comp->memb, ref->memb))
260#define FNP(memb,fun) MATCH (fun (&comp->memb, &ref->memb)) 260#define FNP(memb,fun) MATCH (fun (&comp->memb, &ref->memb))
261 261
262 EQ (mode); 262 EQ (mode);
263 FN (tag, safe_strcmp); 263 FN (tag, safe_strcmp);
264 FN (program, safe_strcmp); 264 FN (program, safe_strcmp);
@@ -299,7 +299,7 @@ complist_find_match (int idx, struct component *ref)
299{ 299{
300 struct complist *list = &comp_list[idx]; 300 struct complist *list = &comp_list[idx];
301 struct component *comp; 301 struct component *comp;
302 302
303 for (comp = list->head; comp && component_match (comp, ref); 303 for (comp = list->head; comp && component_match (comp, ref);
304 comp = comp->next) 304 comp = comp->next)
305 ; 305 ;
@@ -331,7 +331,7 @@ component_merge (struct component *comp, struct component *ref)
331 pies_acl_free (comp->list_acl); 331 pies_acl_free (comp->list_acl);
332 comp->list_acl = ref->list_acl; 332 comp->list_acl = ref->list_acl;
333 ref->list_acl = NULL; 333 ref->list_acl = NULL;
334 334
335 pies_acl_free (comp->adm_acl); 335 pies_acl_free (comp->adm_acl);
336 comp->adm_acl = ref->adm_acl; 336 comp->adm_acl = ref->adm_acl;
337 ref->adm_acl = NULL; 337 ref->adm_acl = NULL;
@@ -396,13 +396,13 @@ static void
396report_cyclic_dependency (pies_depmap_t dp, size_t idx) 396report_cyclic_dependency (pies_depmap_t dp, size_t idx)
397{ 397{
398 size_t i; 398 size_t i;
399 399
400 i = idx; 400 i = idx;
401 do 401 do
402 { 402 {
403 size_t n; 403 size_t n;
404 pies_depmap_pos_t pos; 404 pies_depmap_pos_t pos;
405 405
406 logmsg_printf (LOG_NOTICE, "%s -> ", comp_array[i]->tag); 406 logmsg_printf (LOG_NOTICE, "%s -> ", comp_array[i]->tag);
407 comp_array[i]->flags |= CF_REMOVE; 407 comp_array[i]->flags |= CF_REMOVE;
408 for (n = depmap_first (depmap, depmap_col, i, &pos); 408 for (n = depmap_first (depmap, depmap_col, i, &pos);
@@ -422,7 +422,7 @@ report_cyclic_dependency (pies_depmap_t dp, size_t idx)
422 } 422 }
423 while (i != idx); 423 while (i != idx);
424 logmsg_printf (LOG_NOTICE, "%s\n", comp_array[idx]->tag); 424 logmsg_printf (LOG_NOTICE, "%s\n", comp_array[idx]->tag);
425} 425}
426 426
427void 427void
428comp_array_remove (size_t i) 428comp_array_remove (size_t i)
@@ -440,7 +440,7 @@ component_build_depmap (void)
440{ 440{
441 size_t i; 441 size_t i;
442 pies_depmap_t dp; 442 pies_depmap_t dp;
443 443
444 free (depmap); 444 free (depmap);
445 depmap = depmap_alloc (comp_count); 445 depmap = depmap_alloc (comp_count);
446 for (i = 0; i < comp_count; ) 446 for (i = 0; i < comp_count; )
@@ -465,7 +465,7 @@ component_build_depmap (void)
465 } 465 }
466 depmap_set (depmap, i, tgt); 466 depmap_set (depmap, i, tgt);
467 } 467 }
468 468
469 if (comp->depend) 469 if (comp->depend)
470 for (ep = comp->depend->head; ep; ep = ep->next) 470 for (ep = comp->depend->head; ep; ep = ep->next)
471 { 471 {
@@ -480,7 +480,7 @@ component_build_depmap (void)
480 } 480 }
481 depmap_set (depmap, tgt, i); 481 depmap_set (depmap, tgt, i);
482 } 482 }
483 483
484 i++; 484 i++;
485 } 485 }
486 486
@@ -494,7 +494,7 @@ component_build_depmap (void)
494 report_cyclic_dependency (dp, i); 494 report_cyclic_dependency (dp, i);
495 } 495 }
496 496
497 497
498 for (i = 0; i < comp_count;) 498 for (i = 0; i < comp_count;)
499 if (comp_array[i]->flags & CF_REMOVE) 499 if (comp_array[i]->flags & CF_REMOVE)
500 { 500 {
@@ -503,7 +503,7 @@ component_build_depmap (void)
503 } 503 }
504 else 504 else
505 i++; 505 i++;
506 506
507 free (dp); 507 free (dp);
508} 508}
509 509
@@ -552,7 +552,7 @@ component_config_commit (void)
552 progman_foreach (mark_prog, NULL); 552 progman_foreach (mark_prog, NULL);
553 pies_schedule_children (PIES_CHLD_GC); 553 pies_schedule_children (PIES_CHLD_GC);
554 } 554 }
555 555
556 /* Build dependency map */ 556 /* Build dependency map */
557 component_build_depmap (); 557 component_build_depmap ();
558 558
@@ -603,7 +603,7 @@ component_verify (struct component *comp, grecs_locus_t *locus)
603 else if (!comp->argv) 603 else if (!comp->argv)
604 COMPERR (grecs_error, 604 COMPERR (grecs_error,
605 "%s", _("missing command line")); 605 "%s", _("missing command line"));
606 606
607 if (ISCF_TCPMUX (comp->flags)) 607 if (ISCF_TCPMUX (comp->flags))
608 { 608 {
609 comp->mode = pies_comp_inetd; 609 comp->mode = pies_comp_inetd;
@@ -616,7 +616,7 @@ component_verify (struct component *comp, grecs_locus_t *locus)
616 COMPERR (grecs_error, 616 COMPERR (grecs_error,
617 "%s", _("\"internal\" used without \"service\"")); 617 "%s", _("\"internal\" used without \"service\""));
618 } 618 }
619 619
620 if (comp->pass_fd_socket && comp->mode != pies_comp_pass_fd) 620 if (comp->pass_fd_socket && comp->mode != pies_comp_pass_fd)
621 COMPERR (grecs_error, 621 COMPERR (grecs_error,
622 "%s", _("pass-fd-socket ignored: wrong mode")); 622 "%s", _("pass-fd-socket ignored: wrong mode"));
@@ -627,7 +627,7 @@ component_verify (struct component *comp, grecs_locus_t *locus)
627 COMPERR (grecs_error, 627 COMPERR (grecs_error,
628 "%s", _("socket ignored: wrong mode")); 628 "%s", _("socket ignored: wrong mode"));
629 break; 629 break;
630 630
631 case pies_comp_pass_fd: 631 case pies_comp_pass_fd:
632 if (!comp->pass_fd_socket) 632 if (!comp->pass_fd_socket)
633 COMPERR (grecs_error, 633 COMPERR (grecs_error,
@@ -646,7 +646,7 @@ component_verify (struct component *comp, grecs_locus_t *locus)
646 "file name or chdir must be specified")); 646 "file name or chdir must be specified"));
647 } 647 }
648 /* Fall through */ 648 /* Fall through */
649