| 123 | } |
| 124 | |
| 125 | int IORoutine::run() { |
| 126 | co_enable_hook_sys(); |
| 127 | |
| 128 | while (true) { |
| 129 | if (client_fd_ == -1) { |
| 130 | io_routine_mgr_->AddIORoutine(this); |
| 131 | yield(); |
| 132 | continue; |
| 133 | } |
| 134 | |
| 135 | int byte_size_tot = 0; |
| 136 | do { |
| 137 | SetNoDelay(client_fd_); |
| 138 | int read_proxy_hdr = proxy_protocol_handler_->ProcessProxyHeader(client_fd_); |
| 139 | if (read_proxy_hdr < 0) { |
| 140 | LOG_ERR("process proxy protocol failed, ret %d", read_proxy_hdr); |
| 141 | break; |
| 142 | } |
| 143 | LOG_DEBUG("process proxy protocol succ, header size %d", read_proxy_hdr); |
| 144 | |
| 145 | int fd = io_router_->ConnectDest(); |
| 146 | if (fd < 0) { |
| 147 | LOG_ERR("connect dest failed, ret %d", fd); |
| 148 | break; |
| 149 | } |
| 150 | LOG_DEBUG("connect dest succ, fd %d", fd); |
| 151 | sqlsvr_fd_ = fd; |
| 152 | SetNoDelay(sqlsvr_fd_); |
| 153 | |
| 154 | int send_proxy_hdr = proxy_protocol_handler_->SendProxyHeader(sqlsvr_fd_); |
| 155 | if (send_proxy_hdr < 0) { |
| 156 | LOG_ERR("send proxy protocol failed, ret %d", send_proxy_hdr); |
| 157 | break; |
| 158 | } |
| 159 | LOG_DEBUG("send proxy protocol succ, header size %d", send_proxy_hdr); |
| 160 | |
| 161 | byte_size_tot = io_channel_->TransMsg(client_fd_, sqlsvr_fd_); |
| 162 | LOG_DEBUG("trans %d bytes msg in total", byte_size_tot); |
| 163 | } while (0); |
| 164 | |
| 165 | if (byte_size_tot == 0) { |
| 166 | io_router_->MarkFailure(); |
| 167 | } |
| 168 | |
| 169 | ClearAll(); |
| 170 | } |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | //IORoutine end |
| 175 |
no test coverage detected