aboutsummaryrefslogtreecommitdiff
path: root/src/progman.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-05-26 21:43:47 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-05-26 21:43:47 +0300
commitfdca6812437e642228fdfdfb511cf866ee40fad1 (patch)
tree9b15e1c5aa54d17bf9033c6f13028d22161c2618 /src/progman.c
parente839f7c7d4d8fe3cba672b47b7636de7d9df2ee6 (diff)
downloadpies-fdca6812437e642228fdfdfb511cf866ee40fad1.tar.gz
pies-fdca6812437e642228fdfdfb511cf866ee40fad1.tar.bz2
Fix saturation of the connection table.
* src/progman.c (conn_class_copy): Zero out the source after copying (fix typo). (conn_class_lookup): Bail out if grecs_symtab_lookup_or_install fails. (conn_class_report): Take two arguments, the first one being the priority to use for logging. All uses changed. (conn_class_remove): New function. (progman_cleanup): Call conn_class_remove when the number of connections for that class reaches zero.
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.