MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / accept_loop

Method accept_loop

net/kernel_socket.cpp:433–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431 }
432
433 int accept_loop() {
434 if (workth) LOG_ERROR_RETURN(EALREADY, -1, "Already listening");
435 workth = photon::CURRENT;
436 DEFER(workth = nullptr);
437 while (workth) {
438 waiting = true;
439 auto connection = accept();
440 waiting = false;
441 if (!workth) return 0;
442 if (connection) {
443 connection->timeout(m_timeout);
444 photon::thread_create11(&KernelSocketServer::handler, m_handler, connection);
445 } else {
446 LOG_WARN("KernelSocketServer: failed to accept new connections: `", ERRNO());
447 photon::thread_usleep(1000);
448 }
449 }
450 return 0;
451 }
452
453 static void handler(Handler m_handler, ISocketStream* sess) {
454 m_handler(sess);

Callers

nothing calls this directly

Calls 5

acceptFunction · 0.85
thread_create11Function · 0.50
ERRNOClass · 0.50
thread_usleepFunction · 0.50
timeoutMethod · 0.45

Tested by

no test coverage detected