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
eb59e458
Unverified
Commit
eb59e458
authored
Mar 08, 2019
by
Dennis Jenkins
Committed by
GitHub
Mar 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #485 from knowledge4igor/fix_flaky_tests_caused_by_timeout_problem
Fix flaky tests caused by timeout problem
parents
40276083
f4c74ddd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
include/pistache/client.h
include/pistache/client.h
+5
-1
src/client/client.cc
src/client/client.cc
+4
-5
No files found.
include/pistache/client.h
View file @
eb59e458
...
...
@@ -231,7 +231,7 @@ private:
:
resolve
(
std
::
move
(
resolve
))
,
reject
(
std
::
move
(
reject
))
,
connection
(
connection
)
,
timer
(
std
::
move
(
timer
)
)
,
timer
(
timer
)
,
buffer
(
std
::
move
(
buf
))
{
}
...
...
@@ -248,7 +248,11 @@ private:
PollableQueue
<
ConnectionEntry
>
connectionsQueue
;
std
::
unordered_map
<
Fd
,
ConnectionEntry
>
connections
;
std
::
unordered_map
<
Fd
,
std
::
weak_ptr
<
Connection
>>
timeouts
;
using
Lock
=
std
::
mutex
;
using
Guard
=
std
::
lock_guard
<
Lock
>
;
Lock
timeoutsLock
;
void
asyncSendRequestImpl
(
const
RequestEntry
&
req
,
WriteStatus
status
=
FirstTry
);
...
...
src/client/client.cc
View file @
eb59e458
...
...
@@ -156,6 +156,7 @@ Transport::onReady(const Aio::FdSet& fds) {
}
}
else
{
Guard
guard
(
timeoutsLock
);
auto
timerIt
=
timeouts
.
find
(
fd
);
if
(
timerIt
!=
std
::
end
(
timeouts
))
{
...
...
@@ -163,16 +164,13 @@ Transport::onReady(const Aio::FdSet& fds) {
if
(
connection
)
{
handleTimeout
(
connection
);
timeouts
.
erase
(
fd
);
}
else
{
throw
std
::
runtime_error
(
"Connection error: problem with handling timeout"
);
}
}
else
{
throw
std
::
runtime_error
(
"Unknown fd"
);
}
}
}
else
{
...
...
@@ -223,7 +221,7 @@ Transport::asyncSendRequest(
return
Async
::
Promise
<
ssize_t
>
([
&
](
Async
::
Resolver
&
resolve
,
Async
::
Rejection
&
reject
)
{
auto
ctx
=
context
();
RequestEntry
req
(
std
::
move
(
resolve
),
std
::
move
(
reject
),
connection
,
std
::
move
(
timer
)
,
std
::
move
(
buffer
));
RequestEntry
req
(
std
::
move
(
resolve
),
std
::
move
(
reject
),
connection
,
timer
,
std
::
move
(
buffer
));
if
(
std
::
this_thread
::
get_id
()
!=
ctx
.
thread
())
{
requestsQueue
.
push
(
std
::
move
(
req
));
}
else
{
...
...
@@ -266,6 +264,7 @@ Transport::asyncSendRequestImpl(
totalWritten
+=
bytesWritten
;
if
(
totalWritten
==
len
)
{
if
(
req
.
timer
)
{
Guard
guard
(
timeoutsLock
);
timeouts
.
insert
(
std
::
make_pair
(
req
.
timer
->
fd
,
conn
));
req
.
timer
->
registerReactor
(
key
(),
reactor
());
...
...
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