MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / loop

Method loop

net/TcpConnection.cpp:236–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236void TcpConnection::loop() {
237 auto status = [&] {
238 td::ChainBufferReader *input_ptr;
239 if (socket_pipe_) {
240 TRY_STATUS(socket_pipe_.flush_read());
241 input_ptr = &socket_pipe_.input_buffer();
242 } else {
243 TRY_STATUS(simple_pipe_.flush_read());
244 input_ptr = &simple_pipe_.input_buffer();
245 }
246 auto &input = *input_ptr;
247 bool exit_loop = false;
248 if (!received_attestation_) {
249 TRY_RESULT(attested_peer_info, cocoon::framed_tl_read<RATLSAttestedPeerInfo>(input));
250 if (!attested_peer_info) {
251 exit_loop = true;
252 } else {
253 process_attestation((*attested_peer_info).report());
254 }
255 }
256 while (!exit_loop) {
257 TRY_STATUS(receive(input, exit_loop));
258 }
259 if (socket_pipe_) {
260 TRY_STATUS(socket_pipe_.flush_write());
261 } else {
262 TRY_STATUS(simple_pipe_.flush_write());
263 }
264
265 /*if (td::can_close(buffered_fd_)) {
266 LOG(INFO) << "tcp: stopping (can close)";
267 stop();
268 }*/
269 return td::Status::OK();
270 }();
271 if (status.is_error()) {
272 fail(status.move_as_error_prefix("tcp: client got error: "));
273 }
274}
275
276td::Status TcpConnection::receive_packet(td::BufferSlice data) {
277 LOG(DEBUG) << "tcp: received packet of size " << data.size();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected