MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / run

Method run

src/Server/DistributedQuery/ExchangeServer.cpp:87–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void ExchangeServer::run()
88{
89 while (!stopped)
90 {
91 Poco::Timespan timeout(250000);
92 try
93 {
94 if (server_socket.poll(timeout, Poco::Net::Socket::SELECT_READ))
95 {
96 Poco::Net::StreamSocket socket;
97 try
98 {
99 socket = server_socket.acceptConnection();
100 }
101 // Termination request
102 catch (Poco::InvalidArgumentException &)
103 {
104 break;
105 }
106
107 /// Run the handshake on the pool, not inline, so a slow peer does not stall the
108 /// accept loop and block subsequent connections. Drop the connection if the pool
109 /// rejects the job (queue full or shutting down).
110 try
111 {
112 handshake_pool.scheduleOrThrowOnError(
113 [accepted = socket, conns = connections, task_log = log]()
114 {
115 try
116 {
117 handleConnection(accepted, conns, task_log);
118 }
119 catch (...)
120 {
121 tryLogCurrentException(task_log);
122 }
123 });
124 }
125 catch (...)
126 {
127 tryLogCurrentException(log);
128 }
129 }
130 }
131 catch (Poco::Exception &)
132 {
133 tryLogCurrentException(log);
134 Poco::Thread::sleep(50);
135 }
136 }
137}
138
139namespace
140{

Callers

nothing calls this directly

Calls 5

tryLogCurrentExceptionFunction · 0.50
sleepFunction · 0.50
pollMethod · 0.45
acceptConnectionMethod · 0.45

Tested by

no test coverage detected