Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
8049aeb5
Commit
8049aeb5
authored
Sep 20, 2018
by
gejun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Socket.GetAgentSocket & Print socket differently
parent
528bc8cb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
socket.cpp
src/brpc/socket.cpp
+0
-0
socket.h
src/brpc/socket.h
+30
-17
No files found.
src/brpc/socket.cpp
View file @
8049aeb5
This diff is collapsed.
Click to expand it.
src/brpc/socket.h
View file @
8049aeb5
...
...
@@ -412,24 +412,42 @@ public:
// True if this socket was created by Connect.
bool
CreatedByConnect
()
const
;
/////////////// Pooled sockets ////////////////
// Get a (unused) socket from _shared_part->socket_pool, address it into
// `poole_socket'.
static
int
GetPooledSocket
(
Socket
*
main_socket
,
SocketUniquePtr
*
pooled_socket
);
// Return the socket (which must be got from GetPooledSocket) to its
// _main_socket's pool and reset _main_socket to NULL.
// Get an UNUSED socket connecting to the same place as this socket
// from the SocketPool of this socket.
int
GetPooledSocket
(
SocketUniquePtr
*
pooled_socket
);
// Return this socket which MUST be got from GetPooledSocket to its
// main_socket's pool.
int
ReturnToPool
();
// True if this socket has SocketPool
bool
HasSocketPool
()
const
;
// Put all sockets in _shared_part->socket_pool into `list'.
void
ListPooledSockets
(
std
::
vector
<
SocketId
>*
list
,
size_t
max_count
=
0
);
// Return true on success
bool
GetPooledSocketStats
(
int
*
numfree
,
int
*
numinflight
);
// Create a socket connecting to the same place of main_socket.
static
int
GetShortSocket
(
Socket
*
main_socket
,
SocketUniquePtr
*
short_socket
);
// Create a socket connecting to the same place as this socket.
int
GetShortSocket
(
SocketUniquePtr
*
short_socket
);
// Get and persist a socket connecting to the same place as this socket.
// If an agent socket was already created and persisted, it's returned
// directly (provided other constraints are satisfied)
// If `checkfn' is not NULL, and the checking result on the socket that
// would be returned is false, the socket is abadoned and the getting
// process is restarted.
// For example, http2 connections may run out of stream_id after long time
// running and a new socket should be created. In order not to affect
// LoadBalancers or NamingServices that may reference the Socket, agent
// socket can be used for the communication and replaced periodically but
// the main socket is unchanged.
int
GetAgentSocket
(
SocketUniquePtr
*
out
,
bool
(
*
checkfn
)(
Socket
*
));
// Take a peek at existing agent socket (no creation).
// Returns 0 on success.
int
PeekAgentSocket
(
SocketUniquePtr
*
out
)
const
;
// Where the stats of this socket are accumulated to.
SocketId
main_socket_id
()
const
;
...
...
@@ -741,6 +759,8 @@ private:
int
_error_code
;
std
::
string
_error_text
;
butil
::
atomic
<
SocketId
>
_agent_socket_id
;
butil
::
Mutex
_pipeline_mutex
;
std
::
deque
<
PipelinedInfo
>*
_pipeline_q
;
...
...
@@ -761,13 +781,6 @@ private:
butil
::
Mutex
_stream_mutex
;
std
::
set
<
StreamId
>
*
_stream_set
;
// In some protocols, certain resources may run out according to
// protocol spec. For example, http2 streamId would run out after
// long time running and a new socket should be created. In order
// not to affect main socket, _agent_socket are introduced to
// represent the communication socket.
SocketUniquePtr
_agent_socket
;
};
}
// namespace brpc
...
...
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