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
e8939664
Unverified
Commit
e8939664
authored
Jan 28, 2020
by
Dennis Jenkins
Committed by
GitHub
Jan 28, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #688 from hyperxor/small_code_cleanup_in_client
Small code cleanup in Client side
parents
0dee2f6c
dcf3ce49
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 @
e8939664
...
@@ -202,9 +202,6 @@ private:
...
@@ -202,9 +202,6 @@ private:
void
handleWritableEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleWritableEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleHangupEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleHangupEntry
(
const
Aio
::
FdSet
::
Entry
&
entry
);
void
handleIncoming
(
std
::
shared_ptr
<
Connection
>
connection
);
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
)
{
void
Transport
::
onReady
(
const
Aio
::
FdSet
&
fds
)
{
...
@@ -270,10 +267,9 @@ void Transport::asyncSendRequestImpl(const RequestEntry &req,
...
@@ -270,10 +267,9 @@ void Transport::asyncSendRequestImpl(const RequestEntry &req,
ssize_t
totalWritten
=
0
;
ssize_t
totalWritten
=
0
;
for
(;;)
{
for
(;;)
{
ssize_t
bytesWritten
=
0
;
const
char
*
data
=
buffer
.
data
()
+
totalWritten
;
ssize_t
len
=
buffer
.
size
()
-
totalWritten
;
const
ssize_t
len
=
buffer
.
size
()
-
totalWritten
;
auto
ptr
=
buffer
.
data
()
+
totalWritten
;
const
ssize_t
bytesWritten
=
::
send
(
fd
,
data
,
len
,
0
);
bytesWritten
=
::
send
(
fd
,
ptr
,
len
,
0
);
if
(
bytesWritten
<
0
)
{
if
(
bytesWritten
<
0
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
status
==
FirstTry
)
{
if
(
status
==
FirstTry
)
{
...
@@ -357,7 +353,7 @@ void Transport::handleReadableEntry(const Aio::FdSet::Entry &entry) {
...
@@ -357,7 +353,7 @@ void Transport::handleReadableEntry(const Aio::FdSet::Entry &entry) {
if
(
timerIt
!=
std
::
end
(
timeouts
))
{
if
(
timerIt
!=
std
::
end
(
timeouts
))
{
auto
connection
=
timerIt
->
second
.
lock
();
auto
connection
=
timerIt
->
second
.
lock
();
if
(
connection
)
{
if
(
connection
)
{
handleTimeout
(
connection
);
connection
->
handleTimeout
(
);
timeouts
.
erase
(
fd
);
timeouts
.
erase
(
fd
);
}
}
}
}
...
@@ -410,7 +406,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
...
@@ -410,7 +406,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
if
(
bytes
==
-
1
)
{
if
(
bytes
==
-
1
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
if
(
totalBytes
>
0
)
{
if
(
totalBytes
>
0
)
{
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
connection
->
handleResponsePacket
(
buffer
,
totalBytes
);
}
}
}
else
{
}
else
{
connection
->
handleError
(
strerror
(
errno
));
connection
->
handleError
(
strerror
(
errno
));
...
@@ -418,7 +414,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
...
@@ -418,7 +414,7 @@ void Transport::handleIncoming(std::shared_ptr<Connection> connection) {
break
;
break
;
}
else
if
(
bytes
==
0
)
{
}
else
if
(
bytes
==
0
)
{
if
(
totalBytes
>
0
)
{
if
(
totalBytes
>
0
)
{
handleResponsePacket
(
connection
,
buffer
,
totalBytes
);
connection
->
handleResponsePacket
(
buffer
,
totalBytes
);
}
else
{
}
else
{
connection
->
handleError
(
"Remote closed connection"
);
connection
->
handleError
(
"Remote closed connection"
);
}
}
...
@@ -437,16 +433,6 @@ void Transport::handleIncoming(std::shared_ptr<Connection> 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
)
{
Connection
::
Connection
()
:
fd_
(
-
1
),
requestEntry
(
nullptr
)
{
state_
.
store
(
static_cast
<
uint32_t
>
(
State
::
Idle
));
state_
.
store
(
static_cast
<
uint32_t
>
(
State
::
Idle
));
connectionState_
.
store
(
NotConnected
);
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