This function can be used to kick the main thread out of
poll_job_request() function in case someone wants to re-schedule rrd
processing.
As a starter, a notify call is added at the end of worker processing
when the last worker thread exits. The only purpose of this feature is
to make the main thread to print out the time of the next scheduled
job to be processed, making it just easier to follow the daemon as it
operates.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
static int workers_active;
static int worker_count;
static int workers_active;
static int worker_count;
+static int job_notify_fd[2];
+
static int run_work_on_queue(struct work_queue *queue)
{
struct work_struct *work;
static int run_work_on_queue(struct work_queue *queue)
{
struct work_struct *work;
* ensures next time we start spawning worker threads
* the first thread will have number zero on its name.
*/
* ensures next time we start spawning worker threads
* the first thread will have number zero on its name.
*/
+ /*
+ * Kick the job poller, just to print the time of next
+ * update on the logs
+ */
+ notify_job_request();
+ }
+
mutex_unlock(&work_stats_mutex);
return NULL;
mutex_unlock(&work_stats_mutex);
return NULL;
+static int job_notify_handler(struct event_handler *h)
+{
+ int ret;
+ char buf[64];
+
+ ret = read(job_notify_fd[0], buf, sizeof(buf));
+ if (ret < 0)
+ pr_err("Failed to read: %m\n");
+
+ return 0;
+}
+
/*
* Initialize the jobcontrol.
*
/*
* Initialize the jobcontrol.
*
*/
int init_jobcontrol(int max_jobs_requested)
{
*/
int init_jobcontrol(int max_jobs_requested)
{
+ static struct event_handler ev;
FILE *file;
int ret;
char buf[256];
FILE *file;
int ret;
char buf[256];
+ ret = pipe(job_notify_fd);
+ if (ret) {
+ pr_err("pipe() failed: %m\n");
+ return ret;
+ }
+
+ ev.fd = job_notify_fd[0];
+ ev.events = EPOLLIN;
+ ev.handle_event = job_notify_handler;
+ ev.name = "job_notify";
+ register_event_handler(&ev, EPOLL_CTL_ADD);
+
open_fail:
read_fail:
fclose(file);
open_fail:
read_fail:
fclose(file);
+int notify_job_request(void)
+{
+ int ret;
+ char byte = 0;
+
+ ret = write(job_notify_fd[1], &byte, sizeof(byte));
+ if (ret < 0)
+ pr_err("Failed to write: %m\n");
+
+ return 0;
+}
+
int do_fork(void)
{
int child;
int do_fork(void)
{
int child;
int init_jobcontrol(int max_jobs_requested);
int poll_job_requests(int timeout);
int init_jobcontrol(int max_jobs_requested);
int poll_job_requests(int timeout);
+int notify_job_request(void);
int do_fork(void);
int run(const char *p, char *const argv[]);
int clear_zombie(int pid);
int do_fork(void);
int run(const char *p, char *const argv[]);
int clear_zombie(int pid);