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
58d7804d
Commit
58d7804d
authored
Apr 04, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: eliminate SetExpired(), call Close() directly
parent
ea5e6d8f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
53 deletions
+16
-53
Client.hxx
src/client/Client.hxx
+1
-11
Event.cxx
src/client/Event.cxx
+2
-2
Expire.cxx
src/client/Expire.cxx
+3
-14
Idle.cxx
src/client/Idle.cxx
+0
-3
New.cxx
src/client/New.cxx
+1
-1
Process.cxx
src/client/Process.cxx
+9
-10
Read.cxx
src/client/Read.cxx
+0
-5
Write.cxx
src/client/Write.cxx
+0
-7
No files found.
src/client/Client.hxx
View file @
58d7804d
...
...
@@ -112,19 +112,9 @@ public:
using
FullyBufferedSocket
::
GetEventLoop
;
bool
IsConnected
()
const
noexcept
{
return
FullyBufferedSocket
::
IsDefined
();
}
gcc_pure
bool
IsExpired
()
const
noexcept
{
return
!
FullyBufferedSocket
::
IsDefined
();
}
void
Close
()
noexcept
;
void
SetExpired
()
noexcept
;
bool
Write
(
const
void
*
data
,
size_t
length
)
noexcept
;
using
FullyBufferedSocket
::
Write
;
/**
* Write a null-terminated string.
...
...
src/client/Event.cxx
View file @
58d7804d
...
...
@@ -25,11 +25,11 @@ Client::OnSocketError(std::exception_ptr ep) noexcept
{
FormatError
(
ep
,
"error on client %d"
,
num
);
SetExpired
();
Close
();
}
void
Client
::
OnSocketClosed
()
noexcept
{
SetExpired
();
Close
();
}
src/client/Expire.cxx
View file @
58d7804d
...
...
@@ -22,22 +22,11 @@
#include "Log.hxx"
void
Client
::
SetExpired
()
noexcept
{
if
(
IsExpired
())
return
;
FullyBufferedSocket
::
Close
();
timeout_event
.
Schedule
(
std
::
chrono
::
steady_clock
::
duration
::
zero
());
}
void
Client
::
OnTimeout
()
noexcept
{
if
(
!
IsExpired
())
{
assert
(
!
idle_waiting
);
FormatDebug
(
client_domain
,
"[%u] timeout"
,
num
);
}
assert
(
!
idle_waiting
);
FormatDebug
(
client_domain
,
"[%u] timeout"
,
num
);
Close
();
}
src/client/Idle.cxx
View file @
58d7804d
...
...
@@ -54,9 +54,6 @@ Client::IdleNotify() noexcept
void
Client
::
IdleAdd
(
unsigned
flags
)
noexcept
{
if
(
IsExpired
())
return
;
idle_flags
|=
flags
;
if
(
idle_waiting
&&
(
idle_flags
&
idle_subscriptions
))
IdleNotify
();
...
...
src/client/New.cxx
View file @
58d7804d
...
...
@@ -81,7 +81,7 @@ Client::Close() noexcept
{
partition
->
instance
.
client_list
->
Remove
(
*
this
);
SetExpired
();
FullyBufferedSocket
::
Close
();
FormatInfo
(
client_domain
,
"[%u] closed"
,
num
);
delete
this
;
...
...
src/client/Process.cxx
View file @
58d7804d
...
...
@@ -42,9 +42,7 @@ Client::ProcessCommandList(bool list_ok,
FormatDebug
(
client_domain
,
"process command
\"
%s
\"
"
,
cmd
);
auto
ret
=
command_process
(
*
this
,
n
++
,
cmd
);
FormatDebug
(
client_domain
,
"command returned %i"
,
int
(
ret
));
if
(
IsExpired
())
return
CommandResult
::
CLOSE
;
else
if
(
ret
!=
CommandResult
::
OK
)
if
(
ret
!=
CommandResult
::
OK
)
return
ret
;
else
if
(
list_ok
)
Write
(
"list_OK
\n
"
);
...
...
@@ -89,9 +87,11 @@ Client::ProcessLine(char *line) noexcept
if
(
cmd_list
.
IsActive
())
{
if
(
StringIsEqual
(
line
,
CLIENT_LIST_MODE_END
))
{
const
unsigned
id
=
num
;
FormatDebug
(
client_domain
,
"[%u] process command list"
,
num
);
id
);
const
bool
ok_mode
=
cmd_list
.
IsOKMode
();
auto
list
=
cmd_list
.
Commit
();
...
...
@@ -101,7 +101,7 @@ Client::ProcessLine(char *line) noexcept
std
::
move
(
list
));
FormatDebug
(
client_domain
,
"[%u] process command "
"list returned %i"
,
num
,
int
(
ret
));
"list returned %i"
,
id
,
int
(
ret
));
if
(
ret
==
CommandResult
::
OK
)
command_success
(
*
this
);
...
...
@@ -127,16 +127,15 @@ Client::ProcessLine(char *line) noexcept
cmd_list
.
Begin
(
true
);
return
CommandResult
::
OK
;
}
else
{
const
unsigned
id
=
num
;
FormatDebug
(
client_domain
,
"[%u] process command
\"
%s
\"
"
,
num
,
line
);
id
,
line
);
auto
ret
=
command_process
(
*
this
,
0
,
line
);
FormatDebug
(
client_domain
,
"[%u] command returned %i"
,
num
,
int
(
ret
));
if
(
IsExpired
())
return
CommandResult
::
CLOSE
;
id
,
int
(
ret
));
if
(
ret
==
CommandResult
::
OK
)
command_success
(
*
this
);
...
...
src/client/Read.cxx
View file @
58d7804d
...
...
@@ -66,10 +66,5 @@ Client::OnSocketInput(void *data, size_t length) noexcept
return
InputResult
::
CLOSED
;
}
if
(
IsExpired
())
{
Close
();
return
InputResult
::
CLOSED
;
}
return
InputResult
::
AGAIN
;
}
src/client/Write.cxx
View file @
58d7804d
...
...
@@ -22,13 +22,6 @@
#include <string.h>
bool
Client
::
Write
(
const
void
*
data
,
size_t
length
)
noexcept
{
/* if the client is going to be closed, do nothing */
return
!
IsExpired
()
&&
FullyBufferedSocket
::
Write
(
data
,
length
);
}
bool
Client
::
Write
(
const
char
*
data
)
noexcept
{
return
Write
(
data
,
strlen
(
data
));
...
...
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