MCPcopy Create free account
hub / github.com/Tencent/phxsql / run

Method run

phxsqlproxy/connection_dispatcher.cpp:44–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44int ConnectionDispatcher::run() {
45 co_enable_hook_sys();
46 while (true) {
47 char buffer[512] = { 0 };
48 int n = RoutineReadWithTimeout(socket_pair_fd_[1], buffer, sizeof(buffer), 1000);
49 if (n > 0) {
50 for (int i = 0; i < n; i += sizeof(int)) {
51 int fd = 0;
52 memcpy(&fd, buffer + i, sizeof(int));
53 if (fd) {
54 SetNonBlock(fd);
55 IORoutine * io_routine = NULL;
56 int get_routine_ret = io_routine_mgr_->GetIORoutine(&io_routine);
57 if (get_routine_ret == 0 && io_routine != NULL) {
58 MonitorPluginEntry::GetDefault()->GetMonitorPlugin()->ResumeRoutine();
59 io_routine->SetClientFD(fd);
60 io_routine->resume();
61 } else {
62 MonitorPluginEntry::GetDefault()->GetMonitorPlugin()->OutOfConn();
63 LogError("%s:%d receive connection but no useful io routine", __func__, __LINE__);
64 close(fd);
65 }
66 }
67 }
68 }
69 }
70 return 0;
71}
72
73int ConnectionDispatcher::AssignFD(int fd) {
74 return RoutineWriteWithTimeout(socket_pair_fd_[0], (const char *) (&fd), sizeof(int), 1000);

Callers

nothing calls this directly

Calls 9

RoutineReadWithTimeoutFunction · 0.85
SetNonBlockFunction · 0.85
LogErrorFunction · 0.85
GetIORoutineMethod · 0.80
ResumeRoutineMethod · 0.80
GetMonitorPluginMethod · 0.80
SetClientFDMethod · 0.80
resumeMethod · 0.80
OutOfConnMethod · 0.80

Tested by

no test coverage detected