-static NTSTATUS smbd_server_connection_loop_once(struct tevent_context *ev_ctx,
- struct smbd_server_connection *conn)
-{
- int timeout;
- int num_pfds = 0;
- int ret;
- bool retry;
-
- timeout = SMBD_SELECT_TIMEOUT * 1000;
-
- /*
- * Are there any timed events waiting ? If so, ensure we don't
- * select for longer than it would take to wait for them.
- */
-
- event_add_to_poll_args(ev_ctx, conn, &conn->pfds, &num_pfds, &timeout);
-
- /* Process a signal and timed events now... */
- if (run_events_poll(ev_ctx, 0, NULL, 0)) {
- return NT_STATUS_RETRY;
- }
-
- {
- int sav;
- START_PROFILE(smbd_idle);
-
- ret = poll(conn->pfds, num_pfds, timeout);
- sav = errno;
-
- END_PROFILE(smbd_idle);
- errno = sav;
- }
-
- if (ret == -1) {
- if (errno == EINTR) {
- return NT_STATUS_RETRY;
- }
- return map_nt_error_from_unix(errno);
- }
-
- retry = run_events_poll(ev_ctx, ret, conn->pfds, num_pfds);
- if (retry) {
- return NT_STATUS_RETRY;
- }
-
- /* Did we timeout ? */
- if (ret == 0) {
- return NT_STATUS_RETRY;
- }
-
- /* should not be reached */
- return NT_STATUS_INTERNAL_ERROR;
-}
-