MCPcopy Create free account
hub / github.com/ceph/ceph / accept

Method accept

src/msg/async/AsyncMessenger.cc:180–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void 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 }

Callers 2

do_requestMethod · 0.45
add_acceptMethod · 0.45

Calls 9

cpp_strerrorFunction · 0.85
get_socket_priorityMethod · 0.80
add_acceptMethod · 0.80
get_addr_slotMethod · 0.80
fdMethod · 0.45
get_stackMethod · 0.45
get_workerMethod · 0.45
get_myaddrsMethod · 0.45

Tested by

no test coverage detected