[Openais] Re: Bug 171 idea

Steven Dake sdake at mvista.com
Wed Oct 27 10:33:51 PDT 2004


Mark

The retry is ok but the nanosleep is troublesome.  sys_nanosleep I
believe uses the standard clock to sleep (which has 1 ms resolution). 
This can be a real problem for performance.  Also openais services
should be completely nonblocking in all respects..  Blocking with
nanosleep is wrong..

Could you try a retry patch without the nanosleep?

Thanks
-steve


On Wed, 2004-10-27 at 09:08, Mark Haverkamp wrote:
> Steve,
> 
> How about something like this.  It tries to send a few times in case the
> pipe is temporarily full.  I don't know if the wait times and retries
> are totally reasonable.
> 
> ===== exec/print.c 1.5 vs edited =====
> --- 1.5/exec/print.c	2004-10-18 11:40:00 -07:00
> +++ edited/exec/print.c	2004-10-27 09:02:03 -07:00
> @@ -74,6 +74,8 @@
>  #define LOG_MODE_FILE       4
>  #define LOG_MODE_SYSLOG     8
>  #define LOG_MODE_STDERR     16
> +#define LOG_SYSLOG_RETRY	100
> +#define LOG_SYSLOG_WAIT_NS	1000
>  
>  int log_syslog_fd = -1;
>  FILE *log_file_fp = 0;
> @@ -117,6 +119,8 @@
>  	struct msghdr msg_log;
>  	struct iovec iov_log;
>  	int res;
> +	int retry = LOG_SYSLOG_RETRY;
> +	struct timespec ts;
>  
>  	if (log_syslog_fd == -1) {
>  		log_syslog_fd = socket (AF_UNIX, SOCK_DGRAM, 0);
> @@ -135,7 +139,21 @@
>  	msg_log.msg_controllen = 0;
>  	msg_log.msg_flags = 0;
>  
> -	res = sendmsg (log_syslog_fd, &msg_log, MSG_NOSIGNAL | MSG_DONTWAIT);
> +	while (--retry) {
> +		res = sendmsg (log_syslog_fd, &msg_log, MSG_NOSIGNAL | MSG_DONTWAIT);
> +		if (res == -1) {
> +			if (errno == EAGAIN) {
> +				ts.tv_sec = 0;
> +				ts.tv_nsec = LOG_SYSLOG_WAIT_NS;
> +				nanosleep(&ts, 0);
> +				continue;
> +			}
> +		}
> +		break;
> +	}
> +	if (res == -1) {
> +		perror("log_syslog: lost message");
> +	}
>  }
>  
>  void internal_log_printf (int logclass, char *string, ...)




More information about the Openais mailing list