41 #include "clientpipe.h" 42 #include "clientpipe.h" 46 static const char *module_str =
"queue_cmd";
60 "queue shows all scheduled tasks with their time of earliest executions,\n" 61 "as well as all tasks currently being processed." 67 handles(
const char *cmd, ssize_t n)
76 struct tm strtime_struct;
78 char buf[ODS_SE_MAXLINE];
82 ldns_rbnode_t* node = LDNS_RBTREE_NULL;
84 (void)cmd; (void)n; (void)dbconn;
88 ods_log_assert(engine);
90 client_printf(sockfd,
"There are no tasks scheduled.\n");
100 client_printf(sockfd,
"Working with [%s] %s\n",
108 client_printf(sockfd,
"There %s %i %s scheduled.\n",
109 (count==1)?
"is":
"are", (
int) count, (count==1)?
"task":
"tasks");
111 strftime(strtime,
sizeof(strtime),
"%c", localtime_r(&now, &strtime_struct));
112 client_printf(sockfd,
"It is now %s (%ld seconds since epoch)\n", (strtime[0]?strtime:
"(null)"), (
long)now);
114 if (nextFireTime > 0) {
115 strftime(strtime,
sizeof(strtime),
"%c", localtime_r(&nextFireTime, &strtime_struct));
116 client_printf(sockfd,
"Next task scheduled %s (%ld seconds since epoch)\n", strtime, (
long)nextFireTime);
117 }
else if (nextFireTime == 0) {
118 client_printf(sockfd,
"Next task scheduled immediately\n");
123 node = ldns_rbtree_first(engine->
taskq->
tasks);
124 while (node && node != LDNS_RBTREE_NULL) {
126 memset(buf, 0, ODS_SE_MAXLINE);
128 client_printf(sockfd,
"%s", buf);
129 node = ldns_rbtree_next(node);
146 usage_flush(
int sockfd)
148 client_printf(sockfd,
154 help_flush(
int sockfd)
156 client_printf(sockfd,
157 "Execute all scheduled tasks immediately.\n\n");
161 handles_flush(
const char *cmd, ssize_t n)
167 run_flush(
int sockfd,
engine_type *engine,
const char *cmd, ssize_t n,
170 (void)cmd; (void)n; (void)dbconn;
172 ods_log_assert(engine);
173 ods_log_assert(engine->
taskq);
177 client_printf(sockfd,
"All tasks scheduled immediately.\n");
183 "flush", &usage_flush, &help_flush, &handles_flush, &run_flush
189 return &funcblock_flush;
void ods_log_debug(const char *format,...)
pthread_mutex_t schedule_lock
int(* run)(int sockfd, struct engine_struct *engine, const char *cmd, ssize_t n, db_connection_t *dbconn)
struct cmd_func_block * queue_funcblock(void)
void(* usage)(int sockfd)
engineconfig_type * config
struct cmd_func_block * flush_funcblock(void)
time_t schedule_time_first(schedule_type *schedule)
const char * task_what2str(int what)
const char * task_who2str(const char *who)
void ods_log_verbose(const char *format,...)
char * task2str(task_type *task, char *buftask)
int(* handles)(const char *cmd, ssize_t n)
void schedule_flush(schedule_type *schedule)
size_t schedule_taskcount(schedule_type *schedule)