log-connection.c revision 183bea41fa640dc8117f3eb45ff935cd81377a84
/* Copyright (c) 2005-2011 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "ioloop.h"
#include "istream.h"
#include "llist.h"
#include "hash.h"
#include "master-interface.h"
#include "master-service.h"
#include "log-connection.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define FATAL_QUEUE_TIMEOUT_MSECS 500
struct log_client {
char *prefix;
unsigned int fatal_logged:1;
};
struct log_connection {
int fd;
int listen_fd;
char *default_prefix;
/* pid -> struct log_client* */
struct hash_table *clients;
unsigned int master:1;
unsigned int handshaked:1;
};
{
struct log_client *client;
}
return client;
}
{
}
const struct failure_line *failure)
{
struct log_client *client;
}
}
static void log_parse_master_line(const char *line)
{
struct log_client *client;
const char *p, *p2;
unsigned int count;
int service_fd;
long pid;
return;
}
i_error("Received master input for invalid service_fd %d: %s",
service_fd, line);
return;
}
/* we haven't seen anything important from this client.
it's not an error. */
return;
}
message. */
else
} else {
}
}
static void
{
struct failure_line failure;
struct failure_context failure_ctx;
const char *prefix;
return;
}
case LOG_TYPE_FATAL:
case LOG_TYPE_PANIC:
break;
case LOG_TYPE_OPTION:
return;
default:
break;
}
i_set_failure_prefix("log: ");
}
{
struct log_service_handshake handshake;
const unsigned char *data;
if (ret < 0) {
i_error("read(log pipe) failed: %m");
return -1;
}
/* this isn't a handshake */
return 0;
}
/* this isn't a handshake */
return 0;
}
i_error("Missing prefix data in handshake");
return -1;
}
i_error("Received master prefix in handshake "
return -1;
}
}
return 0;
}
{
const char *line;
if (!log->handshaked) {
if (log_connection_handshake(log) < 0) {
return;
}
}
/* get new timestamps for every read() */
}
i_error("read(log pipe) failed: %m");
} else {
}
}
{
struct log_connection *log;
return log;
}
{
struct hash_iterate_context *iter;
i_error("close(log connection fd) failed: %m");
}
void log_connections_init(void)
{
}
void log_connections_deinit(void)
{
/* normally we don't exit until all log connections are gone,
but we could get here when we're being killed by a signal */
while (log_connections != NULL)
}