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
99feabe8
Commit
99feabe8
authored
Apr 13, 2021
by
hyperxor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More traces to Peer class, http server test and change id generation
parent
361f2ff2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
include/pistache/peer.h
include/pistache/peer.h
+1
-0
src/common/peer.cc
src/common/peer.cc
+8
-5
tests/http_server_test.cc
tests/http_server_test.cc
+2
-2
No files found.
include/pistache/peer.h
View file @
99feabe8
...
...
@@ -60,6 +60,7 @@ namespace Pistache
private:
void
associateTransport
(
Transport
*
transport
);
Transport
*
transport
()
const
;
static
size_t
getUniqueId
();
Transport
*
transport_
=
nullptr
;
Fd
fd_
=
-
1
;
...
...
src/common/peer.cc
View file @
99feabe8
...
...
@@ -19,9 +19,6 @@ namespace Pistache
{
namespace
Tcp
{
std
::
atomic
<
size_t
>
idCounter
{
0
};
namespace
{
struct
ConcretePeer
:
Peer
...
...
@@ -37,7 +34,7 @@ namespace Pistache
:
fd_
(
fd
)
,
addr
(
addr
)
,
ssl_
(
ssl
)
,
id_
(
idCounter
++
)
,
id_
(
getUniqueId
()
)
{
}
Peer
::~
Peer
()
...
...
@@ -138,7 +135,7 @@ namespace Pistache
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
Peer
&
peer
)
{
const
auto
&
addr
=
peer
.
address
();
os
<<
"Peer
with ID="
<<
peer
.
getID
()
<<
" (
address="
<<
addr
os
<<
"Peer
"
<<
&
peer
<<
" (id="
<<
peer
.
getID
()
<<
",
address="
<<
addr
<<
", hostname="
<<
peer
.
hostname
()
<<
", fd="
<<
peer
.
fd
()
<<
")"
;
return
os
;
}
...
...
@@ -153,5 +150,11 @@ namespace Pistache
return
transport_
;
}
size_t
Peer
::
getUniqueId
()
{
static
std
::
atomic
<
size_t
>
idCounter
{
0
};
return
idCounter
++
;
}
}
// namespace Tcp
}
// namespace Pistache
tests/http_server_test.cc
View file @
99feabe8
...
...
@@ -612,13 +612,13 @@ namespace
}
std
::
string
requestAddress
=
request
.
address
().
host
();
writer
.
send
(
Http
::
Code
::
Ok
,
requestAddress
);
std
::
cout
<<
SERVER_PREFIX
<<
" Sent
: `"
<<
requestAddress
<<
"` data
to "
std
::
cout
<<
SERVER_PREFIX
<<
" Sent
`"
<<
requestAddress
<<
"`
to "
<<
*
peer
<<
std
::
endl
;
}
void
onDisconnection
(
const
std
::
shared_ptr
<
Tcp
::
Peer
>&
peer
)
override
{
std
::
cout
<<
SERVER_PREFIX
<<
" Disconnect from
peer
"
<<
*
peer
std
::
cout
<<
SERVER_PREFIX
<<
" Disconnect from "
<<
*
peer
<<
std
::
endl
;
activeConnections
.
erase
(
peer
->
getID
());
waitHelper
->
increment
();
...
...
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