[syslog-ng] leak problems
Balazs Scheidler
bazsi@balabit.hu
Sat, 3 Jun 2000 16:18:09 +0200
--CE+1k2dSO48ffgeK
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Hi,
for those experiencing high memory loads on behalf of syslog-ng, please try
the attached patch, and check whether memory usage changes.
diff -urN syslog-ng-1.4.4/src/affile.c syslog-ng-1.4.5/src/affile.c
--- syslog-ng-1.4.4/src/affile.c Fri Jun 2 20:14:02 2000
+++ syslog-ng-1.4.5/src/affile.c Sat Jun 3 12:24:30 2000
@@ -110,12 +110,6 @@
make_log_reader(0, c),=20
NULL);
res =3D REMEMBER_RESOURCE(cfg->resources, &self->src->super.super);
-#if 0
- if (self->flags & AFFILE_PIPE) {
- self->src->super.close_callback =3D=20
- make_driver_reinit_on_close(c, res, 0, cfg);
- }
-#endif
return ST_OK | ST_GOON;
}
else {
diff -urN syslog-ng-1.4.4/src/afinet.c syslog-ng-1.4.5/src/afinet.c
--- syslog-ng-1.4.4/src/afinet.c Tue Feb 22 18:50:29 2000
+++ syslog-ng-1.4.5/src/afinet.c Sat Jun 3 15:01:10 2000
@@ -242,8 +242,9 @@
self->super.num_connections =3D 0;
{
FOR_OBJECT_QUEUE(p, n) {
- CAST_SUBTYPE(log_handler, h, n);
- append_log_handler(h, self->super.super.super.next);
+ CAST_SUBTYPE(afsocket_source_connection, h, n);
+ h->owner =3D &self->super;
+ append_log_handler(&h->super, self->super.super.super.next);
self->super.num_connections++;
}
}
@@ -392,6 +393,7 @@
struct persistent_config *persistent)
{
CAST(afinet_dest, self, c);
+ struct connect_fd *conn_fd;
int fd;
=20
self->cfg =3D cfg;
@@ -410,11 +412,13 @@
}
if (!self->dest_buf)
self->dest_buf =3D make_pkt_buffer(self->super.super.log_fifo_size);
-
- if (io_connect(cfg->backend,=20
- fd,=20
- self->super.dest_addr,=20
- make_afsocket_dest_connected(cfg->backend, &self->super))) {
+ conn_fd =3D io_connect(cfg->backend,=20
+ fd,=20
+ self->super.dest_addr,=20
+ make_afsocket_dest_connected(cfg->backend, &self->super));
+ =20
+ if (conn_fd) {
+ REMEMBER_RESOURCE(cfg->resources, &conn_fd->super.super);
return ST_OK | ST_GOON;
}
else {
@@ -430,6 +434,10 @@
CAST(afinet_dest, self, c);
struct resource_node *n;
=20
+ if (!self->cfg->living) {
+ werror("Connection established for an old configuration, dropping...\n");
+ return ST_CLOSE | ST_OK;
+ }
if (self->dest)
self->dest->buffer =3D NULL;
if (server) {
diff -urN syslog-ng-1.4.4/src/afunix.c syslog-ng-1.4.5/src/afunix.c
--- syslog-ng-1.4.4/src/afunix.c Tue Feb 22 18:50:29 2000
+++ syslog-ng-1.4.5/src/afunix.c Sat Jun 3 15:01:15 2000
@@ -201,8 +201,9 @@
self->super.num_connections =3D 0;
{
FOR_OBJECT_QUEUE(p, n) {
- CAST_SUBTYPE(log_handler, h, n);
- append_log_handler(h, self->super.super.super.next);
+ CAST_SUBTYPE(afsocket_source_connection, h, n);
+ h->owner =3D &self->super;
+ append_log_handler(&h->super, self->super.super.super.next);
self->super.num_connections++;
}
}
@@ -357,6 +358,8 @@
make_afsocket_dest_connected(cfg->backend, &self->super));
=20
if (conn_fd) {
+ REMEMBER_RESOURCE(cfg->resources, &conn_fd->super.super);
+
return ST_OK | ST_GOON;
}
else {
@@ -375,6 +378,10 @@
CAST(afunix_dest, self, c);
struct resource_node *n;
=20
+ if (!self->cfg->living) {
+ werror("Connection established for an old configuration, dropping...\n");
+ return ST_CLOSE | ST_OK;
+ }
if (self->dest)
self->dest->buffer =3D NULL;
if (server) {
diff -urN syslog-ng-1.4.4/src/cfgfile.c syslog-ng-1.4.5/src/cfgfile.c
--- syslog-ng-1.4.4/src/cfgfile.c Fri Mar 10 12:35:26 2000
+++ syslog-ng-1.4.5/src/cfgfile.c Sat Jun 3 14:30:03 2000
@@ -197,6 +197,7 @@
struct log_dest_group *d;
struct log_source_group *s;
=20
+ self->living =3D 1;
for (s =3D self->sources; s; s =3D s->next_source_group) {
if (s->super.super.destroy)
LOG_HANDLER_DESTROY(s, self, persistent);
@@ -228,6 +229,7 @@
self->init =3D do_init_config;
self->destroy =3D do_destroy_config;
self->backend =3D backend;
+ self->living =3D 1;
self->sync_freq =3D 0;
self->mark_freq =3D 1200; /* 20 minutes */
self->chain_hostnames =3D 1;
diff -urN syslog-ng-1.4.4/src/cfgfile.h syslog-ng-1.4.5/src/cfgfile.h
--- syslog-ng-1.4.4/src/cfgfile.h Fri Mar 24 11:57:28 2000
+++ syslog-ng-1.4.5/src/cfgfile.h Sat Jun 3 14:00:56 2000
@@ -43,6 +43,7 @@
(destroy method int "struct persistent_config *")
(resources object resource_list)
(backend object io_backend)
+ (living simple int)
; global options
(chain_hostnames simple UINT32)
(keep_hostname simple UINT32)
diff -urN syslog-ng-1.4.4/src/cfgfile.h.x syslog-ng-1.4.5/src/cfgfile.h.x
--- syslog-ng-1.4.4/src/cfgfile.h.x Fri Mar 24 11:59:45 2000
+++ syslog-ng-1.4.5/src/cfgfile.h.x Sat Jun 3 14:04:46 2000
@@ -6,6 +6,7 @@
int (*(destroy))(struct syslog_config *self, struct persistent_config *);
struct resource_list *resources;
struct io_backend *backend;
+ int living;
UINT32 chain_hostnames;
UINT32 keep_hostname;
UINT32 mark_freq;
diff -urN syslog-ng-1.4.4/src/main.c syslog-ng-1.4.5/src/main.c
--- syslog-ng-1.4.4/src/main.c Fri Mar 10 12:35:27 2000
+++ syslog-ng-1.4.5/src/main.c Sat Jun 3 14:29:55 2000
@@ -28,6 +28,7 @@
#include "afinter.h"
#include "format.h"
#include "werror.h"
+#include "queue.h"
=20
#include <sys/types.h>
#include <sys/wait.h>
@@ -84,7 +85,6 @@
self->backend->newconfig =3D self->backend->oldconfig;
self->backend->oldconfig =3D NULL;
io_callout(&self->backend->super, 0, c);
-
}
break;
case 3:
@@ -150,8 +150,14 @@
break;
if (sighuprecvd && !restarting) {
=20
+ FOR_QUEUE(&backend->super.callouts, struct ol_queue_node *, n) {
+ ol_queue_remove(n);
+ ol_space_free(n);
+ }
+
notice("SIGHUP received, restarting syslog-ng\n");
restarting =3D 1;
+
backend->newconfig =3D make_syslog_config(cfgfilename, &backend->super);
if (backend->newconfig) {
static struct reread_config r =3D=20
--=20
Bazsi
PGP info: KeyID 9AF8D0A9 Fingerprint CD27 CFB0 802C 0944 9CFD 804E C82C 8EB1
url: http://www.balabit.hu/pgpkey.txt
--CE+1k2dSO48ffgeK
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iQEVAwUBOTkToMGXIGCa+NCpAQETQwf9FsV8TbC3WuaVidLBfksIep7esSY23gk6
HyUAVWlHDG70tQkShbnIat068i4JDjK45RHMavrYCXXsXx3+/THBZ7hgpo/cs+LK
n5A54ccFY9hj7Ldch13TGkdDn+t6Uxc/FDn5mxP2kurmUpqe1+hlCOu6opTeFyB1
68f5Jfn6ayg/LMU3KtWy3ZaodVCR3S5fdm/iHz2kiyezSpVhU253pypLSKB/fKa1
GlJpfyyn5WCFiiz+cRSZezb8yd7Gj0eojd7TllP1+W+0J5J5Ekx3FxcSuYachMFE
SLZ/oHV+/wUnxWxqaBMmeVcXZUKdsHOwz1VrhFHC6Mngtl67Nlz/zQ==
=m+TY
-----END PGP SIGNATURE-----
--CE+1k2dSO48ffgeK--