3
在dyups_module的ngx_http_dyups_init_process
函数里面,有以下代码片段,用于在woker意外退出之后被master重新拉起时的执行逻辑,这里看起来的意图是要解决woker间的配置一致性问题,但仔细看逻辑好像并没有起到任何作用。请问这段逻辑的意图何在呢?
if (sh->version != 0) {
ngx_shmtx_unlock(&shpool->mutex);
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
"[dyups] process start after abnormal exits");
ngx_msleep(dmcf->read_msg_timeout * 2);
ngx_time_update();
tp = ngx_timeofday();
now = (ngx_msec_t) (tp->sec * 1000 + tp->msec);
ngx_shmtx_lock(&shpool->mutex);
if (sh->status == NULL) {
ngx_shmtx_unlock(&shpool->mutex);
return NGX_OK;
}
status = &sh->status[0];
for (i = 1; i < ccf->worker_processes; i++) {
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
"[dyups] process %P %ui %ui",
sh->status[i].pid, status->time, sh->status[i].time);
if (status->time > sh->status[i].time) {
status = &sh->status[i];
}
}
pid = status->pid;
status->time = now;
status->pid = ngx_pid;
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
"[dyups] new process is %P, old process is %P",
ngx_pid, pid);
ngx_dyups_purge_msg(pid, ngx_pid);
}