Skip to content
Snippets Groups Projects
Commit 30cc2d1a authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Lazily process new tasks (prefer current XFR tasks).

Throttled TCP master doesn't block current connections, so
it is not an issue.

fixes #1542
parent 3c68e1db
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ typedef struct tcp_worker_t {
/*
* Forward decls.
*/
#define TCP_THROTTLE_LO 10 /*!< Minimum recovery time on errors. */
#define TCP_THROTTLE_LO 5 /*!< Minimum recovery time on errors. */
#define TCP_THROTTLE_HI 50 /*!< Maximum recovery time on errors. */
/*! \brief Calculate TCP throttle time (random). */
......@@ -290,7 +290,6 @@ static int tcp_accept(int fd)
/* Evaluate connection. */
if (incoming < 0) {
int en = errno;
/*! \todo Better solution so it doesn't block current connections (issue #1542). */
if (en != EINTR) {
log_server_error("Cannot accept connection "
"(%d).\n", errno);
......
......@@ -1500,16 +1500,12 @@ int xfr_worker(dthread_t *thread)
int rfd = evqueue_pollfd(w->q);
fdset_it_t it;
fdset_begin(w->fdset, &it);
int rfd_event = 0;
while(nfds > 0) {
/* Check if it request. */
if (it.fd == rfd) {
dbg_xfr_verb("xfr: worker=%p processing request\n",
w);
ret = xfr_process_request(w, buf, buflen);
if (ret == KNOTD_ENOTRUNNING) {
break;
}
rfd_event = 1; /* Delay new tasks after processing. */
} else {
/* Find data. */
data = xfr_handler_task(w, it.fd);
......@@ -1536,6 +1532,12 @@ int xfr_worker(dthread_t *thread)
}
}
/* Lazily process new tasks. */
if (rfd_event) {
dbg_xfr_verb("xfr: worker=%p processing request\n", w);
ret = xfr_process_request(w, buf, buflen);
}
/* Sweep inactive. */
timev_t now;
if (time_now(&now) == 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment