| 41 | } |
| 42 | |
| 43 | void InfoFunc |
| 44 | ( |
| 45 | RedisModuleInfoCtx *ctx, |
| 46 | int for_crash_report |
| 47 | ) { |
| 48 | // make sure information is requested for crash report |
| 49 | if(!for_crash_report) return; |
| 50 | |
| 51 | // pause all working threads |
| 52 | // NOTE: pausing is not an atomic action; |
| 53 | // other threads can potentially change states before being interrupted. |
| 54 | ThreadPools_Pause(); |
| 55 | |
| 56 | // #readers + #writers + Redis main thread |
| 57 | uint32_t n = ThreadPools_ThreadCount() + 1; |
| 58 | CommandCtx* commands[n]; |
| 59 | Globals_GetCommandCtxs(commands, &n); |
| 60 | |
| 61 | RedisModule_InfoAddSection(ctx, "executing commands"); |
| 62 | |
| 63 | for(int i = 0; i < n; i++) { |
| 64 | CommandCtx *cmd = commands[i]; |
| 65 | ASSERT(cmd != NULL); |
| 66 | |
| 67 | int rc __attribute__((unused)); |
| 68 | char *command_desc = NULL; |
| 69 | rc = asprintf(&command_desc, "%s %s", cmd->command_name, cmd->query); |
| 70 | RedisModule_InfoAddFieldCString(ctx, "command", command_desc); |
| 71 | |
| 72 | free(command_desc); |
| 73 | CommandCtx_Free(cmd); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | void crashHandler |
| 78 | ( |
nothing calls this directly
no test coverage detected