unsigned int version_received:1;
unsigned int handshaked:1;
+ unsigned int master:1;
};
struct anvil_connection *anvil_connections = NULL;
*error_r = "KILL: Not enough parameters";
return -1;
}
- if (conn->fd != MASTER_LISTEN_FD_FIRST) {
+ if (!conn->master) {
*error_r = "KILL sent by a non-master connection";
return -1;
}
}
}
-struct anvil_connection *anvil_connection_create(int fd)
+struct anvil_connection *anvil_connection_create(int fd, bool master)
{
struct anvil_connection *conn;
conn->input = i_stream_create_fd(fd, MAX_INBUF_SIZE, FALSE);
conn->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
conn->io = io_add(fd, IO_READ, anvil_connection_input, conn);
+ conn->master = master;
DLLIST_PREPEND(&anvil_connections, conn);
return conn;
}
#ifndef ANVIL_CONNECTION_H
#define ANVIL_CONNECTION_H
-struct anvil_connection *anvil_connection_create(int fd);
+struct anvil_connection *anvil_connection_create(int fd, bool master);
void anvil_connection_destroy(struct anvil_connection *conn);
void anvil_connections_destroy_all(void);
#include "array.h"
#include "env-util.h"
#include "master-service.h"
+#include "master-interface.h"
#include "connect-limit.h"
#include "anvil-connection.h"
static void client_connected(const struct master_service_connection *conn)
{
- anvil_connection_create(conn->fd);
+ bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
+
+ anvil_connection_create(conn->fd, master);
}
int main(int argc, char *argv[])