[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: library/2679: vsyslog(3) leaves unsent messages



The following reply was made to PR library/2679; it has been noted by GNATS.

From: "Todd C. Miller" <Todd.Miller@courtesan.com>
To: Javier Kohen <jkohen@corest.com>
Cc: gnats@openbsd.org
Subject: Re: library/2679: vsyslog(3) leaves unsent messages 
Date: Mon, 03 Jun 2002 12:39:52 -0600

 The following diff fixes this.  I haven't decided whether or not
 to add a usleep() between the calls to send() or not (to prevent
 the process from spinning).
 
  - todd
 
 --- /usr/src/lib/libc/gen//syslog.c	Sun May 26 12:11:25 2002
 +++ /tmp/syslog.c	Mon Jun  3 12:37:32 2002
 @@ -268,13 +268,19 @@
  		return;
  
  	/*
 -	 * If the send() failed, the odds are syslogd was restarted.
 -	 * Make one (only) attempt to reconnect to /dev/log.
 +	 * If the send() failed, there are two likely scenarios:
 +	 *  1) syslogd was restarted
 +	 *  2) /dev/log is out of socket buffer space
 +	 * We attempt to reconnect to /dev/log to take care of
 +	 * case #1 and keep send()ing data to cover case #2
 +	 * to give syslogd a chance to empty its socket buffer.
  	 */
  	disconnectlog_r(data);
  	connectlog_r(data);
 -	if (send(data->log_file, tbuf, cnt, 0) >= 0)
 -		return;
 +	do {
 +		if (send(data->log_file, tbuf, cnt, 0) >= 0)
 +			return;
 +	} while (errno == ENOBUFS);
  
  	/*
  	 * Output the message to the console; try not to block