| 252 | } |
| 253 | |
| 254 | static apr_status_t run_watchdog(int state, void *baton, apr_pool_t *ptemp) |
| 255 | { |
| 256 | md_renew_ctx_t *dctx = baton; |
| 257 | md_job_t *job; |
| 258 | apr_time_t next_run, wait_time; |
| 259 | int i; |
| 260 | |
| 261 | /* mod_watchdog invoked us as a single thread inside the whole server (on this machine). |
| 262 | * This might be a repeated run inside the same child (mod_watchdog keeps affinity as |
| 263 | * long as the child lives) or another/new child. |
| 264 | */ |
| 265 | switch (state) { |
| 266 | case AP_WATCHDOG_STATE_STARTING: |
| 267 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10054) |
| 268 | "md watchdog start, auto drive %d mds", dctx->jobs->nelts); |
| 269 | break; |
| 270 | |
| 271 | case AP_WATCHDOG_STATE_RUNNING: |
| 272 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10055) |
| 273 | "md watchdog run, auto drive %d mds", dctx->jobs->nelts); |
| 274 | |
| 275 | /* Process all drive jobs. They will update their next_run property |
| 276 | * and we schedule ourself at the earliest of all. A job may specify 0 |
| 277 | * as next_run to indicate that it wants to participate in the normal |
| 278 | * regular runs. */ |
| 279 | next_run = next_run_default(dctx); |
| 280 | for (i = 0; i < dctx->jobs->nelts; ++i) { |
| 281 | job = APR_ARRAY_IDX(dctx->jobs, i, md_job_t *); |
| 282 | |
| 283 | if (apr_time_now() >= job->next_run) { |
| 284 | process_drive_job(dctx, job, ptemp); |
| 285 | } |
| 286 | |
| 287 | if (job->next_run && job->next_run < next_run) { |
| 288 | next_run = job->next_run; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | wait_time = next_run - apr_time_now(); |
| 293 | if (APLOGdebug(dctx->s)) { |
| 294 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10107) |
| 295 | "next run in %s", md_duration_print(ptemp, wait_time)); |
| 296 | } |
| 297 | wd_set_interval(dctx->watchdog, wait_time, dctx, run_watchdog); |
| 298 | break; |
| 299 | |
| 300 | case AP_WATCHDOG_STATE_STOPPING: |
| 301 | ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, dctx->s, APLOGNO(10058) |
| 302 | "md watchdog stopping"); |
| 303 | break; |
| 304 | } |
| 305 | |
| 306 | return APR_SUCCESS; |
| 307 | } |
| 308 | |
| 309 | apr_status_t md_renew_start_watching(md_mod_conf_t *mc, server_rec *s, apr_pool_t *p) |
| 310 | { |
nothing calls this directly
no test coverage detected