Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
e0fd63ec
Commit
e0fd63ec
authored
Aug 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved code to sockaddr_to_tmp_string()
Unclutter the client_new() constructor by moving unrelated complex code into a separate function.
parent
34735fab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
client.c
src/client.c
+17
-9
No files found.
src/client.c
View file @
e0fd63ec
...
@@ -248,16 +248,10 @@ static void client_close(struct client *client)
...
@@ -248,16 +248,10 @@ static void client_close(struct client *client)
free
(
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
;
const
char
*
hostname
;
struct
client
*
client
;
if
(
num_clients
>=
client_max_connections
)
{
ERROR
(
"Max Connections Reached!
\n
"
);
xclose
(
fd
);
return
;
}
switch
(
addr
->
sa_family
)
{
switch
(
addr
->
sa_family
)
{
#ifdef HAVE_TCP
#ifdef HAVE_TCP
...
@@ -293,11 +287,25 @@ void client_new(int fd, const struct sockaddr *addr)
...
@@ -293,11 +287,25 @@ void client_new(int fd, const struct sockaddr *addr)
hostname
=
"unknown"
;
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
));
client
=
xcalloc
(
1
,
sizeof
(
*
client
));
list_add
(
&
client
->
siblings
,
&
clients
);
list_add
(
&
client
->
siblings
,
&
clients
);
++
num_clients
;
++
num_clients
;
client_init
(
client
,
fd
);
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
)
static
int
client_process_line
(
struct
client
*
client
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment