moved code to sockaddr_to_tmp_string()
Unclutter the client_new() constructor by moving unrelated complex code into a separate function.
This commit is contained in:
parent
34735fab66
commit
e0fd63ecf8
26
src/client.c
26
src/client.c
@ -248,16 +248,10 @@ static void client_close(struct client *client)
|
||||
free(client);
|
||||
}
|
||||
|
||||
void client_new(int fd, const struct sockaddr *addr)
|
||||
static const char *
|
||||
sockaddr_to_tmp_string(const struct sockaddr *addr)
|
||||
{
|
||||
const char *hostname;
|
||||
struct client *client;
|
||||
|
||||
if (num_clients >= client_max_connections) {
|
||||
ERROR("Max Connections Reached!\n");
|
||||
xclose(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (addr->sa_family) {
|
||||
#ifdef HAVE_TCP
|
||||
@ -293,11 +287,25 @@ void client_new(int fd, const struct sockaddr *addr)
|
||||
hostname = "unknown";
|
||||
}
|
||||
|
||||
return hostname;
|
||||
}
|
||||
|
||||
void client_new(int fd, const struct sockaddr *addr)
|
||||
{
|
||||
struct client *client;
|
||||
|
||||
if (num_clients >= client_max_connections) {
|
||||
ERROR("Max Connections Reached!\n");
|
||||
xclose(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
client = xcalloc(1, sizeof(*client));
|
||||
list_add(&client->siblings, &clients);
|
||||
++num_clients;
|
||||
client_init(client, fd);
|
||||
SECURE("client %i: opened from %s\n", client->num, hostname);
|
||||
SECURE("client %i: opened from %s\n", client->num,
|
||||
sockaddr_to_tmp_string(addr));
|
||||
}
|
||||
|
||||
static int client_process_line(struct client *client)
|
||||
|
Loading…
Reference in New Issue
Block a user