log.c revision eddd9bf1a1369aea4a2715f6be1137da6d17d293
/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "ioloop.h"
#include "istream.h"
#include "fd-set-nonblock.h"
#include "fd-close-on-exec.h"
#include "child-process.h"
#include "log.h"
#include <unistd.h>
struct log_io {
int refcount;
unsigned int log_counter;
unsigned int max_lines_per_sec;
char *prefix;
char next_log_type;
unsigned int throttle_msg:1;
unsigned int destroying:1;
};
static unsigned int throttle_count;
static void log_throttle_timeout(void *context);
{
const char *line;
bool ret;
log_io->log_counter = 0;
}
);
if (!ret)
return FALSE;
}
return TRUE;
}
{
if (!log_io->throttle_msg) {
FALSE);
}
return;
}
}
{
}
{
return;
timeout_remove(&to);
}
{
struct child_process *process;
const char *prefix;
/* our internal protocol.
\001 + log_type */
line += 2;
} else {
}
}
switch (log_io->next_log_type) {
case 'I':
break;
case 'W':
break;
case 'E':
break;
case 'F':
case 'P':
break;
default:
break;
}
if (!continues)
!log_io->destroying) {
return 0;
}
return 1;
}
{
const unsigned char *data;
const char *line;
int ret;
if (!log_write_pending(log_io))
return 0;
if (ret < 0) {
if (ret == -1) {
/* closed */
return -1;
}
/* buffer full. treat it as one line */
return 0;
}
if (!log_write_pending(log_io))
return 0;
return 0;
}
{
int fd[2];
i_error("pipe() failed: %m");
return -1;
}
return fd[1];
}
{
}
{
}
{
}
{
const unsigned char *data;
if (log_io->destroying)
return;
/* if there was something in buffer, write it */
(void)log_write_pending(log_io);
/* write partial data as well */
if (size != 0) {
);
}
else
else
}
{
return;
}
{
unsigned int left = throttle_count;
if (log_write_pending(log))
if (--left == 0)
break;
}
}
}
void log_init(void)
{
throttle_count = 0;
}
void log_deinit(void)
{
/* do one final log read in case there's still something
waiting */
}
timeout_remove(&to);
}