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
709b795e
Commit
709b795e
authored
Aug 28, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved code to client_write()
Move the second part of client_write_output() into a separate function.
parent
4516bd11
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
26 deletions
+28
-26
client.c
src/client.c
+28
-26
No files found.
src/client.c
View file @
709b795e
...
@@ -744,41 +744,43 @@ static void client_defer_output(struct client *client,
...
@@ -744,41 +744,43 @@ static void client_defer_output(struct client *client,
*
buf_r
=
new_sllnode
(
data
,
length
);
*
buf_r
=
new_sllnode
(
data
,
length
);
}
}
static
void
client_write_output
(
struct
client
*
client
)
static
void
client_write
(
struct
client
*
client
,
const
char
*
data
,
size_t
length
)
{
{
ssize_t
ret
;
ssize_t
ret
;
assert
(
client
->
deferred_send
==
NULL
);
if
((
ret
=
write
(
client
->
fd
,
data
,
length
))
<
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
{
client
->
deferred_send
=
new_sllnode
(
data
,
length
);
}
else
{
DEBUG
(
"client %i: problems writing
\n
"
,
client
->
num
);
client
->
expired
=
1
;
return
;
}
}
else
if
((
size_t
)
ret
<
client
->
send_buf_used
)
{
client
->
deferred_send
=
new_sllnode
(
data
+
ret
,
length
-
ret
);
}
if
(
client
->
deferred_send
)
{
DEBUG
(
"client %i: buffer created
\n
"
,
client
->
num
);
client
->
deferred_bytes
=
client
->
deferred_send
->
size
+
sizeof
(
struct
sllnode
);
}
}
static
void
client_write_output
(
struct
client
*
client
)
{
if
(
client
->
expired
||
!
client
->
send_buf_used
)
if
(
client
->
expired
||
!
client
->
send_buf_used
)
return
;
return
;
if
(
client
->
deferred_send
!=
NULL
)
if
(
client
->
deferred_send
!=
NULL
)
client_defer_output
(
client
,
client
->
send_buf
,
client_defer_output
(
client
,
client
->
send_buf
,
client
->
send_buf_used
);
client
->
send_buf_used
);
else
{
else
if
((
ret
=
write
(
client
->
fd
,
client
->
send_buf
,
client_write
(
client
,
client
->
send_buf
,
client
->
send_buf_used
);
client
->
send_buf_used
))
<
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EINTR
)
{
client
->
deferred_send
=
new_sllnode
(
client
->
send_buf
,
client
->
send_buf_used
);
}
else
{
DEBUG
(
"client %i: problems writing
\n
"
,
client
->
num
);
client
->
expired
=
1
;
return
;
}
}
else
if
((
size_t
)
ret
<
client
->
send_buf_used
)
{
client
->
deferred_send
=
new_sllnode
(
client
->
send_buf
+
ret
,
client
->
send_buf_used
-
ret
);
}
if
(
client
->
deferred_send
)
{
DEBUG
(
"client %i: buffer created
\n
"
,
client
->
num
);
client
->
deferred_bytes
=
client
->
deferred_send
->
size
+
sizeof
(
struct
sllnode
);
}
}
client
->
send_buf_used
=
0
;
client
->
send_buf_used
=
0
;
}
}
...
...
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