MCPcopy Create free account
hub / github.com/apache/brpc / Init

Method Init

src/brpc/socket_map.cpp:184–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184int SocketMap::Init(const SocketMapOptions& options) {
185 if (_options.socket_creator != NULL) {
186 LOG(ERROR) << "Already initialized";
187 return -1;
188 }
189 _options = options;
190 if (_options.socket_creator == NULL) {
191 LOG(ERROR) << "SocketOptions.socket_creator must be set";
192 return -1;
193 }
194 if (_map.init(_options.suggested_map_size, 70) != 0) {
195 LOG(ERROR) << "Fail to init _map";
196 return -1;
197 }
198 if (_options.idle_timeout_second_dynamic != NULL ||
199 _options.idle_timeout_second > 0) {
200 bthread_attr_t attr = BTHREAD_ATTR_NORMAL;
201 bthread_attr_set_name(&attr, "RunWatchConnections");
202 if (bthread_start_background(&_close_idle_thread, &attr,
203 RunWatchConnections, this) != 0) {
204 LOG(FATAL) << "Fail to start bthread";
205 return -1;
206 }
207 _has_close_idle_thread = true;
208 }
209 return 0;
210}
211
212void SocketMap::Print(std::ostream& os) {
213 // TODO: Elaborate.

Callers 1

Calls 3

bthread_attr_set_nameFunction · 0.85
bthread_start_backgroundFunction · 0.85
initMethod · 0.45

Tested by

no test coverage detected