diff options
| author | Russ White <russ@riw.us> | 2018-06-19 07:28:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-19 07:28:18 -0400 |
| commit | efd1d76673fd62247c0e28ee206eddd26829a951 (patch) | |
| tree | 90f5a8c2a1109e8319f18c7724b4f41a8503398b /lib/thread.c | |
| parent | e3ea4f7acbbf3e7e26f2391286c1cd7e146fd5d9 (diff) | |
| parent | 626e8d0a9b4830438276947d0c76d1fbf4c7884c (diff) | |
Merge pull request #2474 from donaldsharp/vty_thread_cancel_writes
Add 'show thread poll'
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/thread.c b/lib/thread.c index 18e1c92280..1c5e838772 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -296,6 +296,47 @@ DEFUN (show_thread_cpu, return CMD_SUCCESS; } +static void show_thread_poll_helper(struct vty *vty, struct thread_master *m) +{ + const char *name = m->name ? m->name : "main"; + char underline[strlen(name) + 1]; + uint32_t i; + + memset(underline, '-', sizeof(underline)); + underline[sizeof(underline) - 1] = '\0'; + + vty_out(vty, "\nShowing poll FD's for %s\n", name); + vty_out(vty, "----------------------%s\n", underline); + vty_out(vty, "Count: %u\n", (uint32_t)m->handler.pfdcount); + for (i = 0; i < m->handler.pfdcount; i++) + vty_out(vty, "\t%6d fd:%6d events:%2d revents:%2d\n", i, + m->handler.pfds[i].fd, + m->handler.pfds[i].events, + m->handler.pfds[i].revents); +} + +DEFUN (show_thread_poll, + show_thread_poll_cmd, + "show thread poll", + SHOW_STR + "Thread information\n" + "Show poll FD's and information\n") +{ + struct listnode *node; + struct thread_master *m; + + pthread_mutex_lock(&masters_mtx); + { + for (ALL_LIST_ELEMENTS_RO(masters, node, m)) { + show_thread_poll_helper(vty, m); + } + } + pthread_mutex_unlock(&masters_mtx); + + return CMD_SUCCESS; +} + + DEFUN (clear_thread_cpu, clear_thread_cpu_cmd, "clear thread cpu [FILTER]", @@ -325,6 +366,7 @@ DEFUN (clear_thread_cpu, void thread_cmd_init(void) { install_element(VIEW_NODE, &show_thread_cpu_cmd); + install_element(VIEW_NODE, &show_thread_poll_cmd); install_element(ENABLE_NODE, &clear_thread_cpu_cmd); } /* CLI end ------------------------------------------------------------------ */ |
