[Openais] Bug 171 idea
Mark Haverkamp
markh at osdl.org
Wed Oct 27 09:08:20 PDT 2004
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, ...)
--
Mark Haverkamp <markh at osdl.org>
More information about the Openais
mailing list