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
a091c148
Commit
a091c148
authored
Aug 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: added function client_by_fd()
The code becomes less complex and more readable when we move this linear search into a separate mini function.
parent
d15e1e09
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
client.c
src/client.c
+20
-12
No files found.
src/client.c
View file @
a091c148
...
@@ -689,30 +689,38 @@ static void client_write_deferred(struct client *client)
...
@@ -689,30 +689,38 @@ static void client_write_deferred(struct client *client)
}
}
}
}
int
client_print
(
int
fd
,
const
char
*
buffer
,
size_t
buflen
)
static
struct
client
*
client_by_fd
(
int
fd
)
{
{
static
unsigned
int
i
;
static
unsigned
int
i
;
assert
(
fd
>=
0
);
if
(
i
<
client_max_connections
&&
clients
[
i
].
fd
>=
0
&&
clients
[
i
].
fd
==
fd
)
return
&
clients
[
i
];
for
(
i
=
0
;
i
<
client_max_connections
;
i
++
)
if
(
clients
[
i
].
fd
==
fd
)
return
&
clients
[
i
];
return
NULL
;
}
int
client_print
(
int
fd
,
const
char
*
buffer
,
size_t
buflen
)
{
size_t
copylen
;
size_t
copylen
;
struct
client
*
client
;
struct
client
*
client
;
assert
(
fd
>=
0
);
assert
(
fd
>=
0
);
if
(
i
>=
client_max_connections
||
client
=
client_by_fd
(
fd
);
clients
[
i
].
fd
<
0
||
clients
[
i
].
fd
!=
fd
)
{
if
(
client
==
NULL
)
for
(
i
=
0
;
i
<
client_max_connections
;
i
++
)
{
if
(
clients
[
i
].
fd
==
fd
)
break
;
}
if
(
i
==
client_max_connections
)
return
-
1
;
return
-
1
;
}
/* if fd isn't found or client is going to be closed, do nothing */
/* if fd isn't found or client is going to be closed, do nothing */
if
(
client
s
[
i
].
expired
)
if
(
client
->
expired
)
return
0
;
return
0
;
client
=
clients
+
i
;
while
(
buflen
>
0
&&
!
client
->
expired
)
{
while
(
buflen
>
0
&&
!
client
->
expired
)
{
size_t
left
;
size_t
left
;
...
...
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