client: return early in client_new()
This saves one level of indent.
This commit is contained in:
parent
c0197c58ba
commit
d15e1e09a2
61
src/client.c
61
src/client.c
@ -237,6 +237,7 @@ static void client_close(struct client *client)
|
|||||||
void client_new(int fd, const struct sockaddr *addr)
|
void client_new(int fd, const struct sockaddr *addr)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
const char *hostname;
|
||||||
|
|
||||||
for (i = 0; i < client_max_connections
|
for (i = 0; i < client_max_connections
|
||||||
&& clients[i].fd >= 0; i++) /* nothing */ ;
|
&& clients[i].fd >= 0; i++) /* nothing */ ;
|
||||||
@ -244,44 +245,44 @@ void client_new(int fd, const struct sockaddr *addr)
|
|||||||
if (i == client_max_connections) {
|
if (i == client_max_connections) {
|
||||||
ERROR("Max Connections Reached!\n");
|
ERROR("Max Connections Reached!\n");
|
||||||
xclose(fd);
|
xclose(fd);
|
||||||
} else {
|
return;
|
||||||
const char *hostname;
|
}
|
||||||
switch (addr->sa_family) {
|
|
||||||
|
switch (addr->sa_family) {
|
||||||
#ifdef HAVE_TCP
|
#ifdef HAVE_TCP
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
hostname = (const char *)inet_ntoa(((const struct sockaddr_in *)
|
hostname = (const char *)inet_ntoa(((const struct sockaddr_in *)
|
||||||
addr)->sin_addr);
|
addr)->sin_addr);
|
||||||
if (!hostname)
|
if (!hostname)
|
||||||
hostname = "error getting ipv4 address";
|
hostname = "error getting ipv4 address";
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
{
|
{
|
||||||
static char host[INET6_ADDRSTRLEN + 1];
|
static char host[INET6_ADDRSTRLEN + 1];
|
||||||
memset(host, 0, INET6_ADDRSTRLEN + 1);
|
memset(host, 0, INET6_ADDRSTRLEN + 1);
|
||||||
if (inet_ntop(AF_INET6, (const void *)
|
if (inet_ntop(AF_INET6, (const void *)
|
||||||
&(((const struct sockaddr_in6 *)addr)->
|
&(((const struct sockaddr_in6 *)addr)->
|
||||||
sin6_addr), host,
|
sin6_addr), host,
|
||||||
INET6_ADDRSTRLEN)) {
|
INET6_ADDRSTRLEN)) {
|
||||||
hostname = (const char *)host;
|
hostname = (const char *)host;
|
||||||
} else {
|
} else {
|
||||||
hostname = "error getting ipv6 address";
|
hostname = "error getting ipv6 address";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
#endif /* HAVE_TCP */
|
#endif /* HAVE_TCP */
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
case AF_UNIX:
|
case AF_UNIX:
|
||||||
hostname = "local connection";
|
hostname = "local connection";
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_UN */
|
#endif /* HAVE_UN */
|
||||||
default:
|
default:
|
||||||
hostname = "unknown";
|
hostname = "unknown";
|
||||||
}
|
|
||||||
SECURE("client %i: opened from %s\n", i, hostname);
|
|
||||||
client_init(&(clients[i]), fd);
|
|
||||||
}
|
}
|
||||||
|
SECURE("client %i: opened from %s\n", i, hostname);
|
||||||
|
client_init(&(clients[i]), fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int client_process_line(struct client *client)
|
static int client_process_line(struct client *client)
|
||||||
|
Loading…
Reference in New Issue
Block a user