Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fast reload #1015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 65 commits into
base: master
Choose a base branch
Loading
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a399e7b
- fast-reload, add unbound-control fast_reload
wcawijngaards Nov 3, 2023
a38a37d
- fast-reload, make a thread to service the unbound-control command.
wcawijngaards Nov 3, 2023
88a60f0
- fast-reload, communication sockets for information transfer.
wcawijngaards Nov 3, 2023
bc0c9a4
- fast-reload, fix compile for unbound-dnstap-socket.
wcawijngaards Nov 3, 2023
6b00fd4
- fast-reload, set nonblocking communication to keep the server thread
wcawijngaards Nov 6, 2023
2c0f622
- fast-reload, poll routine to test for readiness, timeout fails conn…
wcawijngaards Nov 6, 2023
3e17db1
- fast-reload, detect loop in sock_poll_timeout routine.
wcawijngaards Nov 6, 2023
43ff8e1
- fast-reload, send done and exited notification.
wcawijngaards Nov 7, 2023
dab478d
- fast-reload, defines for constants in ipc.
wcawijngaards Nov 30, 2023
bc95c79
Merge branch 'master' into fast-reload
wcawijngaards Nov 30, 2023
f2c0e22
- fast-reload, ipc socket recv and send resists partial reads and wri…
wcawijngaards Nov 30, 2023
fcfb3fe
- fast-reload, send exit command to thread when done.
wcawijngaards Nov 30, 2023
32e98b4
- fast-reload, output strings for client on string list.
wcawijngaards Dec 1, 2023
c07e941
- fast-reload, add newline to terminal output.
wcawijngaards Dec 4, 2023
9c6d102
- fast-reload, send client string to remote client.
wcawijngaards Dec 4, 2023
d9b965e
- fast-reload, better debug output.
wcawijngaards Dec 4, 2023
caf6419
- fast-reload, print queue structure, for output to the remote client.
wcawijngaards Dec 8, 2023
8f710f0
Merge branch 'master' into fast-reload
wcawijngaards Dec 8, 2023
f93b718
- fast-reload, move print items to print queue from fast_reload_threa…
wcawijngaards Dec 8, 2023
828f6d7
- fast-reload, keep list of pending print queue items in daemon struct.
wcawijngaards Dec 8, 2023
a882c35
- fast-reload, comment explains in_list for printq to print remainder.
wcawijngaards Dec 8, 2023
82c9e9c
- fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
wcawijngaards Jan 4, 2024
6a2b399
Merge branch 'master' into fast-reload
wcawijngaards Jan 4, 2024
cce409c
- fast-reload, fix test link for fast_reload_printq_list_delete funct…
wcawijngaards Jan 4, 2024
85127a4
- fast-reload, reread config file from disk.
wcawijngaards Jan 4, 2024
4304754
- fast-reload, unshare forwards, making the structure locked, with an…
wcawijngaards Jan 4, 2024
091ea9f
- fast-reload, for nonthreaded, the unbound-control commands forward,
wcawijngaards Jan 4, 2024
5436c9c
Merge branch 'master' into fast-reload
wcawijngaards Jan 4, 2024
39e5959
- fast-reload, unshared stub hints, making the structure locked, with…
wcawijngaards Jan 5, 2024
25aa0be
Merge branch 'master' into fast-reload
wcawijngaards Jan 5, 2024
e146a92
- fast-reload, helpful comments for hints lookup function return value.
wcawijngaards Jan 5, 2024
5c3f72d
- fast-reload, fix bug in fast reload printout, the strlist appendlis…
wcawijngaards Jan 8, 2024
94ef337
- fast-reload, keep track of reloadtime and deletestime and print them.
wcawijngaards Jan 8, 2024
38573f4
- fast-reload, keep track of constructtime and print it.
wcawijngaards Jan 8, 2024
53b647e
- fast-reload, construct new items.
wcawijngaards Jan 8, 2024
b0da43e
- fast-reload, better comment.
wcawijngaards Jan 8, 2024
a57c943
- fast-reload, reload the config and swap trees for forwards and stub…
wcawijngaards Jan 9, 2024
9c1274e
- fast-reload, in forwards_swap_tree set protection of trees with locks.
wcawijngaards Jan 9, 2024
b567a5c
- fast-reload, in hints_swap_tree also swap the node count of the trees.
wcawijngaards Jan 9, 2024
eee7d88
- fast-reload, reload ipc to stop and start threads.
wcawijngaards Jan 9, 2024
9e98d17
Merge branch 'master' into fast-reload
wcawijngaards Jan 9, 2024
bcaebb1
- fast-reload, unused forward declarations removed.
wcawijngaards Jan 11, 2024
c3a754f
- fast-reload, unit test that fast reload works with forwards and stubs.
wcawijngaards Jan 22, 2024
a423aa9
Merge branch 'master' into fast-reload
wcawijngaards Jan 22, 2024
c96debd
Merge branch 'master' into fast-reload
wcawijngaards Jan 22, 2024
b28f671
- fast-reload, fix clang analyzer warnings.
wcawijngaards Jan 23, 2024
b62f8cf
Merge branch 'master' into fast-reload
wcawijngaards Jan 23, 2024
3907d00
Merge branch 'master' into fast-reload
wcawijngaards Feb 15, 2024
0b79daf
- fast-reload, small documentation entry in unbound-control -h output.
wcawijngaards Feb 15, 2024
d047c3f
- fast-reload, printout memory use by fast reload, in bytes.
wcawijngaards Mar 19, 2024
b3dbb62
Merge branch 'master' into fast-reload
wcawijngaards Mar 19, 2024
d915c4c
- fast-reload, compile without threads.
wcawijngaards Mar 21, 2024
bebce30
- fast-reload, document fast_reload in man page.
wcawijngaards Mar 21, 2024
942dd56
- fast-reload, print ok when done successfully.
wcawijngaards Mar 21, 2024
2ab619f
- fast-reload, option for fast-reload commandline, +v verbosity option,
wcawijngaards Mar 21, 2024
c97f5a6
- fast-reload, option for fast-reload commandline, +p does not pause …
wcawijngaards Mar 21, 2024
123205c
- fast-reload, option for fast-reload commandline, +d drops mesh quer…
wcawijngaards Mar 21, 2024
46bdbc7
- fast-reload, fix to poll every thread with nopause to make certain …
wcawijngaards Mar 21, 2024
58ff34c
- fast-reload, fix to use atomic store for config variables with nopa…
wcawijngaards Mar 21, 2024
1aa9800
- fast-reload, reload views.
wcawijngaards Apr 5, 2024
3c33eef
Merge branch 'master' into fast-reload
wcawijngaards Apr 5, 2024
cd33d21
- fast-reload, when tag defines are different, it drops the queries.
wcawijngaards Apr 5, 2024
d9cfc8d
- fast-reload, fix tag define check.
wcawijngaards Apr 5, 2024
3c3fa03
Merge branch 'master' into fast-reload
wcawijngaards Apr 5, 2024
d52018a
- fast-reload, document that tag change causes drop of queries.
wcawijngaards Apr 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- fast-reload, send exit command to thread when done.
  • Loading branch information
wcawijngaards committed Nov 30, 2023
commit fcfb3fe5b5dc5b4a67d3176ca827fd7180840ef7
177 changes: 174 additions & 3 deletions 177 daemon/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
/** What number of loop iterations is too much for ipc retries */
#define IPC_LOOP_MAX 200
/** Timeout in msec for ipc socket poll. */
#define IPC_NOTIFICATION_WAIT 20000
#define IPC_NOTIFICATION_WAIT 200

static int
remote_setup_ctx(struct daemon_remote* rc, struct config_file* cfg)
Expand Down Expand Up @@ -3952,12 +3952,113 @@ fast_reload_thread_desetup(struct fast_reload_thread* fast_reload_thread)
free(fast_reload_thread);
}

/** Fast reload, the main thread handles that the fast reload thread has
* exited. */
static void
fr_main_perform_done(struct fast_reload_thread* fr)
{
struct worker* worker = fr->worker;
verbose(VERB_ALGO, "join with fastreload thread");
ub_thread_join(fr->tid);
verbose(VERB_ALGO, "joined with fastreload thread");
fast_reload_thread_desetup(fr);
worker->daemon->fast_reload_thread = NULL;
}

/** Fast reload, perform the command received from the fast reload thread */
static void
fr_main_perform_cmd(struct fast_reload_thread* fr,
enum fast_reload_notification status)
{
verbose(VERB_ALGO, "main perform fast reload status: %s",
fr_notification_to_string(status));
if(status == fast_reload_notification_printout) {
} else if(status == fast_reload_notification_done ||
status == fast_reload_notification_done_error ||
status == fast_reload_notification_exited) {
fr_main_perform_done(fr);
} else {
log_err("main received unknown status from fast reload: %d %s",
(int)status, fr_notification_to_string(status));
}
}

/** Fast reload, handle command from fast reload to the main thread. */
static void
fr_main_handle_cmd(struct fast_reload_thread* fr)
{
enum fast_reload_notification status;
ssize_t ret;
ret = recv(fr->commpair[0],
((char*)&fr->service_read_cmd)+fr->service_read_cmd_count,
sizeof(fr->service_read_cmd)-fr->service_read_cmd_count, 0);
if(ret == -1) {
if(
#ifndef USE_WINSOCK
errno == EINTR || errno == EAGAIN
# ifdef EWOULDBLOCK
|| errno == EWOULDBLOCK
# endif
#else
WSAGetLastError() == WSAEINTR ||
WSAGetLastError() == WSAEINPROGRESS ||
WSAGetLastError() == WSAEWOULDBLOCK
#endif
)
return; /* Continue later. */
log_err("read cmd from fast reload thread, recv: %s",
sock_strerror(errno));
return;
} else if(ret == 0) {
verbose(VERB_ALGO, "closed connection from fast reload thread");
fr->service_read_cmd_count = 0;
/* handle this like an error */
fr->service_read_cmd = fast_reload_notification_done_error;
} else if(ret + (ssize_t)fr->service_read_cmd_count <
(ssize_t)sizeof(fr->service_read_cmd)) {
fr->service_read_cmd_count += ret;
/* Continue later. */
return;
}
status = fr->service_read_cmd;
fr->service_read_cmd = 0;
fr->service_read_cmd_count = 0;
fr_main_perform_cmd(fr, status);
}

/** Fast reload, poll for and handle cmd from fast reload thread. */
static void
fr_check_cmd_from_thread(struct fast_reload_thread* fr)
{
int inevent = 0;
struct worker* worker = fr->worker;
/* Stop in case the thread has exited, or there is no read event. */
while(worker->daemon->fast_reload_thread) {
if(!sock_poll_timeout(fr->commpair[0], 0, 1, 0, &inevent)) {
log_err("check for cmd from fast reload thread: "
"poll failed");
return;
}
if(!inevent)
return;
fr_main_handle_cmd(fr);
}
}

void fast_reload_service_cb(int ATTR_UNUSED(fd), short ATTR_UNUSED(bits),
void* arg)
{
struct fast_reload_thread* fast_reload_thread =
(struct fast_reload_thread*)arg;
(void)fast_reload_thread;
struct worker* worker = fast_reload_thread->worker;

/* Read and handle the command */
fr_main_handle_cmd(fast_reload_thread);
if(worker->daemon->fast_reload_thread != NULL) {
/* If not exited, see if there are more pending statuses
* from the fast reload thread. */
fr_check_cmd_from_thread(fast_reload_thread);
}
}

int fast_reload_client_callback(struct comm_point* c, void* arg, int err,
Expand All @@ -3971,6 +4072,70 @@ int fast_reload_client_callback(struct comm_point* c, void* arg, int err,
return 0;
}

/**
* Fast reload thread, send a command to the thread. Blocking on timeout.
* It handles received input from the thread, if any is received.
*/
static void
fr_send_cmd_to(struct fast_reload_thread* fr,
enum fast_reload_notification status)
{
int outevent, loopexit = 0, bcount = 0;
uint32_t cmd;
ssize_t ret;
verbose(VERB_ALGO, "send notification to fast reload thread: %s",
fr_notification_to_string(status));
cmd = status;
while(1) {
if(++loopexit > IPC_LOOP_MAX) {
log_err("send notification to fast reload: could not send notification: loop");
return;
}
fr_check_cmd_from_thread(fr);
/* wait for socket to become writable */
if(!sock_poll_timeout(fr->commpair[0], IPC_NOTIFICATION_WAIT,
0, 1, &outevent)) {
log_err("send notification to fast reload: poll failed");
return;
}
if(!outevent)
continue;
ret = send(fr->commpair[0], ((char*)&cmd)+bcount,
sizeof(cmd)-bcount, 0);
if(ret == -1) {
if(
#ifndef USE_WINSOCK
errno == EINTR || errno == EAGAIN
# ifdef EWOULDBLOCK
|| errno == EWOULDBLOCK
# endif
#else
WSAGetLastError() == WSAEINTR ||
WSAGetLastError() == WSAEINPROGRESS ||
WSAGetLastError() == WSAEWOULDBLOCK
#endif
)
continue; /* Try again. */
log_err("send notification to fast reload: send: %s",
sock_strerror(errno));
return;
} else if(ret+(ssize_t)bcount != sizeof(cmd)) {
bcount += ret;
if((size_t)bcount < sizeof(cmd))
continue;
}
break;
}
}

/** fast reload thread, send stop command to the thread, from the main thread.
*/
static void
fr_send_stop(struct fast_reload_thread* fr)
{
fr_send_cmd_to(fr, fast_reload_notification_exit);
}

void
fast_reload_thread_start(RES* ssl, struct worker* worker, struct rc_state* s)
{
Expand Down Expand Up @@ -4040,7 +4205,13 @@ fast_reload_thread_start(RES* ssl, struct worker* worker, struct rc_state* s)
void
fast_reload_thread_stop(struct fast_reload_thread* fast_reload_thread)
{
struct worker* worker = fast_reload_thread->worker;
if(!fast_reload_thread)
return;
fast_reload_thread_desetup(fast_reload_thread);
fr_send_stop(fast_reload_thread);
if(worker->daemon->fast_reload_thread != NULL) {
/* If it did not exit yet, join with the thread now. It is
* going to exit because the exit command is sent to it. */
fr_main_perform_done(fast_reload_thread);
}
}
5 changes: 5 additions & 0 deletions 5 daemon/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ struct fast_reload_thread {
/** if the event that listens on the remote service worker has
* been added to the comm base. */
int service_event_is_added;
/** the service event can read a cmd, nonblocking, so it can
* save the partial read cmd here */
uint32_t service_read_cmd;
/** the number of bytes in service_read_cmd */
int service_read_cmd_count;
/** the remote control connection to print output to. */
struct remote_stream remote;
/** the worker that the service_event is added in */
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.