[uClibc]Re: file descriptor (socket) leakage

Tomislav Sajdl tomislav.sajdl at communitymesh.com
Fri May 30 08:03:20 UTC 2003


> But then, based on your earlier bug report, that means that
> calling syslog() a zillion times is opening a zillion sockets and
> thereby leaving a zillion file descriptors open, right?  I took a
> quick look at uClibc's syslog.c and I do not see how that could
> happen though.
>
>  -Erik


This application simulates what freeswan does (our software had problems only 
with WARNINGs, so have that in mind), and I see that _there is_ leakage.

Tomislav

#include <stdio.h>
#include <syslog.h>

int main() {
	const char m[] = "message";
	char wait;

	printf("No syslog called. See /proc/PID/fd and then press Enter.\n");
	wait = getchar();

	openlog("blah", LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
	syslog(LOG_WARNING, "%s", m);

	printf("Openlog and syslog called. See /proc/PID/fd and then press 
Enter.\n");
	wait = getchar();

	syslog(LOG_WARNING, "%s", m);

	printf("One more syslog called. See /proc/PID/fd and then press Enter.\n");
	wait = getchar();

}



More information about the uClibc mailing list