anvil-connection.c revision d19fb2745f553746e283c6fc46c82fb402fc3e9b
/* Copyright (c) 2009-2011 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "llist.h"
#include "istream.h"
#include "ostream.h"
#include "master-service.h"
#include "master-interface.h"
#include "connect-limit.h"
#include "penalty.h"
#include "anvil-connection.h"
#include <stdlib.h>
#include <unistd.h>
#define MAX_INBUF_SIZE 1024
#define ANVIL_CLIENT_PROTOCOL_MAJOR_VERSION 1
#define ANVIL_CLIENT_PROTOCOL_MINOR_VERSION 0
struct anvil_connection {
int fd;
unsigned int version_received:1;
unsigned int handshaked:1;
unsigned int master:1;
unsigned int fifo:1;
};
static const char *const *
{
const char *line;
}
static int
{
args++;
*error_r = "CONNECT: Not enough parameters";
return -1;
}
*error_r = "DISCONNECT: Not enough parameters";
return -1;
}
*error_r = "KILL: Not enough parameters";
return -1;
}
*error_r = "KILL sent by a non-master connection";
return -1;
}
*error_r = "LOOKUP: Not enough parameters";
return -1;
}
*error_r = "LOOKUP on a FIFO, can't send reply";
return -1;
}
*error_r = "PENALTY-GET: Not enough parameters";
return -1;
}
*error_r = "PENALTY-INC: Not enough parameters";
return -1;
}
value > PENALTY_MAX_VALUE ||
*error_r = "PENALTY-INC: Invalid parameters";
return -1;
}
*error_r = "PENALTY-SET-EXPIRE-SECS: "
"Invalid parameters";
return -1;
}
} else {
return -1;
}
return 0;
}
static void anvil_connection_input(void *context)
{
case -2:
i_error("BUG: Anvil client connection sent too much data");
return;
case -1:
return;
}
if (!conn->version_received) {
return;
i_error("Anvil client not compatible with this server "
"(mixed old and new binaries?)");
return;
}
}
break;
}
}
}
}
struct anvil_connection *
{
struct anvil_connection *conn;
if (!fifo)
return conn;
}
{
i_error("close(anvil conn) failed: %m");
if (!fifo)
}
void anvil_connections_destroy_all(void)
{
while (anvil_connections != NULL)
}