Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
dcf3ce49
Commit
dcf3ce49
authored
Jan 29, 2020
by
hyperxor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small code cleanup in Client side
parent
0dee2f6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
20 deletions
+6
-20
src/client/client.cc
src/client/client.cc
+6
-20
No files found.
src/client/client.cc
View file @
dcf3ce49
...
...
@@ -202,9 +202,6 @@ private:
void
handleWritableEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleHangupEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleIncoming
(
std
::
shared_ptr
<
Connection
>
connection
);
void
handleResponsePacket
(
const
std
::
shared_ptr
<
Connection
>
&
connection
,
const
char
*
buffer
,
size_t
totalBytes
);
void
handleTimeout
(
const
std
::
shared_ptr
<
Connection
>
&
connection
);
};
void
Transport
::
onReady
(
const
Aio
::
FdSet
&
fds
)
{
...
...
@@ -270,10 +267,9 @@ void Transport::asyncSendRequestImpl(const RequestEntry &req,
ssize_t
totalWritten
=
0
;
for
(;;)
{
ssize_t
bytesWritten
=
0
;
ssize_t
len
=
buffer
.
size
()
-
totalWritten
;
auto
ptr
=
buffer
.
data
()
+
totalWritten
;
bytesWritten
=
::
send
(
fd
,
ptr
,
len
,
0
);
const
char
*
data
=
buffer
.
data
()
+
totalWritten
;
const
ssize_t
len
=
buffer
.
size
()
-
totalWritten
;
const
ssize_t
bytesWritten
=
::
send
(
fd
,
data
,
len
,
0
);
if
(
bytesWritten
<
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
status
==
FirstTry
)
{
...
...
@@ -357,7 +353,7 @@ void Transport::handleReadableEntry(const Aio::FdSet::Entry &entry) {
if
(
timerIt
!=
std
::
end
(
timeouts
))
{
auto
connection
=
timerIt
->
second
.
lock
();
if
(
connection
)
{
handleTimeout
(
connection
);
connection
->
handleTimeout
(
);
timeouts
.
erase
(
fd
);
}
}
...
...
@@ -410,7 +406,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
if
(
bytes
==
-
1
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
totalBytes
>
0
)
{
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
connection
->
handleResponsePacket
(
buffer
,
totalBytes
);
}
}
else
{
connection
->
handleError
(
strerror
(
errno
));
...
...
@@ -418,7 +414,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
break
;
}
else
if
(
bytes
==
0
)
{
if
(
totalBytes
>
0
)
{
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
connection
->
handleResponsePacket
(
buffer
,
totalBytes
);
}
else
{
connection
->
handleError
(
"Remote closed connection"
);
}
...
...
@@ -437,16 +433,6 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
}
}
void
Transport
::
handleResponsePacket
(
const
std
::
shared_ptr
<
Connection
>
&
connection
,
const
char
*
buffer
,
size_t
totalBytes
)
{
connection
->
handleResponsePacket
(
buffer
,
totalBytes
);
}
void
Transport
::
handleTimeout
(
const
std
::
shared_ptr
<
Connection
>
&
connection
)
{
connection
->
handleTimeout
();
}
Connection
::
Connection
()
:
fd_
(
-
1
),
requestEntry
(
nullptr
)
{
state_
.
store
(
static_cast
<
uint32_t
>
(
State
::
Idle
));
connectionState_
.
store
(
NotConnected
);
...
...
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