| 178 | } |
| 179 | |
| 180 | void Processor::accept() |
| 181 | { |
| 182 | SocketOptions opts; |
| 183 | opts.nodelay = msgr->cct->_conf->ms_tcp_nodelay; |
| 184 | opts.rcbuf_size = msgr->cct->_conf->ms_tcp_rcvbuf; |
| 185 | opts.priority = msgr->get_socket_priority(); |
| 186 | |
| 187 | for (auto& listen_socket : listen_sockets) { |
| 188 | ldout(msgr->cct, 10) << __func__ << " listen_fd=" << listen_socket.fd() |
| 189 | << dendl; |
| 190 | unsigned accept_error_num = 0; |
| 191 | |
| 192 | while (true) { |
| 193 | entity_addr_t addr; |
| 194 | ConnectedSocket cli_socket; |
| 195 | Worker *w = worker; |
| 196 | if (!msgr->get_stack()->support_local_listen_table()) |
| 197 | w = msgr->get_stack()->get_worker(); |
| 198 | else |
| 199 | ++w->references; |
| 200 | int r = listen_socket.accept(&cli_socket, opts, &addr, w); |
| 201 | if (r == 0) { |
| 202 | ldout(msgr->cct, 10) << __func__ << " accepted incoming on sd " |
| 203 | << cli_socket.fd() << dendl; |
| 204 | |
| 205 | msgr->add_accept( |
| 206 | w, std::move(cli_socket), |
| 207 | msgr->get_myaddrs().v[listen_socket.get_addr_slot()], |
| 208 | addr); |
| 209 | accept_error_num = 0; |
| 210 | continue; |
| 211 | } else { |
| 212 | --w->references; |
| 213 | if (r == -EINTR) { |
| 214 | continue; |
| 215 | } else if (r == -EAGAIN) { |
| 216 | break; |
| 217 | } else if (r == -EMFILE || r == -ENFILE) { |
| 218 | lderr(msgr->cct) << __func__ << " open file descriptors limit reached fd = " << listen_socket.fd() |
| 219 | << " errno " << r << " " << cpp_strerror(r) << dendl; |
| 220 | if (++accept_error_num > msgr->cct->_conf->ms_max_accept_failures) { |
| 221 | lderr(msgr->cct) << "Proccessor accept has encountered too many errors, just do ceph_abort()." << dendl; |
| 222 | ceph_abort(); |
| 223 | } |
| 224 | continue; |
| 225 | } else if (r == -ECONNABORTED) { |
| 226 | ldout(msgr->cct, 0) << __func__ << " closed because of rst arrival fd = " << listen_socket.fd() |
| 227 | << " errno " << r << " " << cpp_strerror(r) << dendl; |
| 228 | continue; |
| 229 | } else { |
| 230 | lderr(msgr->cct) << __func__ << " no incoming connection?" |
| 231 | << " errno " << r << " " << cpp_strerror(r) << dendl; |
| 232 | if (++accept_error_num > msgr->cct->_conf->ms_max_accept_failures) { |
| 233 | lderr(msgr->cct) << "Proccessor accept has encountered too many errors, just do ceph_abort()." << dendl; |
| 234 | ceph_abort(); |
| 235 | } |
| 236 | continue; |
| 237 | } |
no test coverage detected