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
7774cd27
Commit
7774cd27
authored
Aug 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: moved code to client_defer_output()
Split the large function client_write_output() into two parts; this is the first code moving patch.
parent
4448b17e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
client.c
src/client.c
+27
-20
No files found.
src/client.c
View file @
7774cd27
...
@@ -719,33 +719,40 @@ int client_print(int fd, const char *buffer, size_t buflen)
...
@@ -719,33 +719,40 @@ int client_print(int fd, const char *buffer, size_t buflen)
return
0
;
return
0
;
}
}
static
void
client_defer_output
(
struct
client
*
client
,
const
void
*
data
,
size_t
length
)
{
struct
sllnode
*
buf
=
client
->
deferred_send
;
assert
(
client
->
deferred_send
!=
NULL
);
client
->
deferred_bytes
+=
sizeof
(
struct
sllnode
)
+
length
;
if
(
client
->
deferred_bytes
>
client_max_output_buffer_size
)
{
ERROR
(
"client %i: output buffer size (%lu) is "
"larger than the max (%lu)
\n
"
,
client
->
num
,
(
unsigned
long
)
client
->
deferred_bytes
,
(
unsigned
long
)
client_max_output_buffer_size
);
/* cause client to close */
client
->
expired
=
1
;
}
else
{
while
(
buf
->
next
)
buf
=
buf
->
next
;
buf
->
next
=
new_sllnode
(
data
,
length
);
}
}
static
void
client_write_output
(
struct
client
*
client
)
static
void
client_write_output
(
struct
client
*
client
)
{
{
ssize_t
ret
;
ssize_t
ret
;
struct
sllnode
*
buf
;
if
(
client
->
expired
||
!
client
->
send_buf_used
)
if
(
client
->
expired
||
!
client
->
send_buf_used
)
return
;
return
;
if
((
buf
=
client
->
deferred_send
))
{
if
(
client
->
deferred_send
!=
NULL
)
client
->
deferred_bytes
+=
sizeof
(
struct
sllnode
)
client_defer_output
(
client
,
client
->
send_buf
,
+
client
->
send_buf_used
;
client
->
send_buf_used
);
if
(
client
->
deferred_bytes
>
else
{
client_max_output_buffer_size
)
{
ERROR
(
"client %i: output buffer size (%lu) is "
"larger than the max (%lu)
\n
"
,
client
->
num
,
(
unsigned
long
)
client
->
deferred_bytes
,
(
unsigned
long
)
client_max_output_buffer_size
);
/* cause client to close */
client
->
expired
=
1
;
}
else
{
while
(
buf
->
next
)
buf
=
buf
->
next
;
buf
->
next
=
new_sllnode
(
client
->
send_buf
,
client
->
send_buf_used
);
}
}
else
{
if
((
ret
=
write
(
client
->
fd
,
client
->
send_buf
,
if
((
ret
=
write
(
client
->
fd
,
client
->
send_buf
,
client
->
send_buf_used
))
<
0
)
{
client
->
send_buf_used
))
<
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
{
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
{
...
...
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