aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/progman.c')
-rw-r--r--src/progman.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/progman.c b/src/progman.c
index d24ea1a..843262e 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -558,8 +558,8 @@ conn_class_free (void *data)
static int
conn_class_copy(void *a, void *b)
{
- memcpy(a, b, sizeof(struct conn_class));
- memset(a, 0, sizeof(struct conn_class));
+ memcpy (a, b, sizeof(struct conn_class));
+ memset (b, 0, sizeof(struct conn_class));
return 0;
}
@@ -604,20 +604,38 @@ conn_class_lookup (const char *tag,
}
ret = grecs_symtab_lookup_or_install (conn_tab, probe, &install);
+ if (!ret)
+ {
+ logmsg (LOG_CRIT, "cannot allocate conn_class: %s",
+ strerror (errno));
+ abort ();
+ }
free (probe);
return ret;
}
static void
-conn_class_report (struct conn_class *pcclass)
+conn_class_report (int prio, struct conn_class *pcclass)
{
char *s = sockaddr_to_astr ((struct sockaddr *)&pcclass->sa_storage,
pcclass->sa_len);
- logmsg (LOG_DEBUG, _("connections in class %s/%s: %lu"),
+ logmsg (prio, _("connections in class %s/%s: %lu"),
pcclass->tag, s, (unsigned long)pcclass->count);
free (s);
}
+static void
+conn_class_remove (struct conn_class *pcclass)
+{
+ if (!conn_tab)
+ {
+ logmsg (LOG_CRIT, "attempt to free unexisting conn_class %p", pcclass);
+ conn_class_report (LOG_CRIT, pcclass);
+ abort ();
+ }
+ grecs_symtab_remove (conn_tab, pcclass);
+}
+
extern char **environ; /* Environment */
static size_t envsize; /* Size of environ. If it is not 0, then we
@@ -1354,7 +1372,7 @@ _prog_accept (struct prog *p)
pcclass->count++;
if (debug_level > 1)
- conn_class_report (pcclass);
+ conn_class_report (LOG_DEBUG, pcclass);
pinst = register_prog0 (p->v.p.comp, -1);
pinst->v.p.socket = fd;
@@ -2306,7 +2324,12 @@ progman_cleanup (int expect_term)
{
prog->v.p.cclass->count--;
if (debug_level > 1)
- conn_class_report (prog->v.p.cclass);
+ conn_class_report (LOG_DEBUG, prog->v.p.cclass);
+ if (prog->v.p.cclass->count == 0)
+ {
+ conn_class_remove (prog->v.p.cclass);
+ prog->v.p.cclass = NULL;
+ }
}
prog_stop_redirectors (prog);

Return to:

Send suggestions and report system problems to the System administrator.