struct cli_showproc_ctx {
int debug;
- int next_uptime; /* uptime must be greater than this value */
+ int next_reload; /* reload number to resume from, 0 = from the beginning */
};
/* Displays workers and processes */
chunk_reset(&trash);
- if (ctx->next_uptime == 0) {
+ if (ctx->next_reload == 0) {
memprintf(&reloadtxt, "%d [failed: %d]", proc_self->reloads, proc_self->failedreloads);
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s", "<PID>", "<type>", "<reloads>", "<uptime>", "<version>");
if (ctx->debug)
ha_free(&uptime);
/* displays current processes */
- if (ctx->next_uptime == 0)
+ if (ctx->next_reload == 0)
chunk_appendf(&trash, "# workers\n");
list_for_each_entry(child, &proc_list, list) {
/* don't display current worker if we only need the next ones */
- if (ctx->next_uptime != 0)
+ if (ctx->next_reload != 0)
continue;
up = date.tv_sec - child->timestamp;
return 0;
/* displays old processes */
- if (old || ctx->next_uptime) { /* there's more */
- if (ctx->next_uptime == 0)
+ if (old || ctx->next_reload) { /* there's more */
+ if (ctx->next_reload == 0)
chunk_appendf(&trash, "# old workers\n");
list_for_each_entry(child, &proc_list, list) {
up = date.tv_sec - child->timestamp;
if (up <= 0) /* must never be negative because of clock drift */
up = 0;
- if (child->timestamp < ctx->next_uptime)
+ /* If we're resuming, skip entries that were already printed (reload >= ctx->next_reload) */
+ if (ctx->next_reload && child->reloads >= ctx->next_reload)
continue;
if (!(child->options & PROC_O_TYPE_WORKER))
chunk_appendf(&trash, "\t\t %-15d %-15d", child->ipc_fd[0], child->ipc_fd[1]);
chunk_appendf(&trash, "\n");
ha_free(&uptime);
- }
- /* start from there if there's not enough place */
- ctx->next_uptime = child->timestamp;
+ /* Try to flush so we can resume after this reload on next page if the buffer is full. */
+ if (applet_putchk(appctx, &trash) == -1) {
+ /* resume at this reload (exclude it on next pass) */
+ ctx->next_reload = child->reloads; /* resume after entries >= this reload */
+ return 0;
+ }
+ chunk_reset(&trash);
+ }
- if (applet_putchk(appctx, &trash) == -1)
- return 0;
}
}
- /* dump complete */
+ /* dump complete: reset resume cursor so next 'show proc' starts from the top */
+ ctx->next_reload = 0;
return 1;
}