MCPcopy Create free account
hub / github.com/apache/trafficserver / run

Method run

src/mgmt/rpc/server/IPCSocketServer.cc:199–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void
200IPCSocketServer::run()
201{
202 _running.store(true);
203
204 while (_running) {
205 // poll till socket it's ready.
206 if (!this->poll_for_new_client()) {
207 if (_running.load()) {
208 Warning("ups, we've got an issue.");
209 }
210 break;
211 }
212
213 std::error_code ec;
214 if (int fd = this->accept(ec); !ec) {
215 Client client{fd, _conf.incomingRequestMaxBufferSize};
216 Buffer bw;
217
218 if (auto [ok, errStr] = client.read_all(bw); ok) {
219 const std::string &json = bw.str();
220 rpc::Context ctx;
221 // we want to make sure the peer's credentials are ok.
222 ctx.get_auth().add_checker(
223 [&](TSRPCHandlerOptions const &opt, swoc::Errata &errata) -> void { late_check_peer_credentials(fd, opt, errata); });
224
225 if (auto response = rpc::JsonRPCManager::instance().handle_call(ctx, json); response) {
226 // seems a valid response.
227 if (client.write(*response, ec); ec) {
228 Dbg(dbg_ctl, "Error sending the response: %s", ec.message().c_str());
229 }
230 } // it was a notification.
231 } else {
232 Dbg(dbg_ctl, "Error detected while reading: %s", errStr.c_str());
233 }
234 } else {
235 Dbg(dbg_ctl, "Error while accepting a new connection on the socket: %s", ec.message().c_str());
236 }
237 }
238
239 this->close();
240}
241
242bool
243IPCSocketServer::stop()

Callers 1

run_threadMethod · 0.45

Calls 12

poll_for_new_clientMethod · 0.95
acceptMethod · 0.95
closeMethod · 0.95
add_checkerMethod · 0.80
storeMethod · 0.45
loadMethod · 0.45
read_allMethod · 0.45
strMethod · 0.45
handle_callMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected