]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cpu_profiler: fix asok command crash
authorliu shi <liu.shi@navercorp.com>
Fri, 14 May 2021 07:51:01 +0000 (03:51 -0400)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Mon, 14 Aug 2023 13:51:35 +0000 (20:51 +0700)
fixes: https://tracker.ceph.com/issues/50814
Signed-off-by: liu shi <liu.shi@navercorp.com>
(cherry picked from commit be7303aafe34ae470d2fd74440c3a8d51fcfa3ff)

src/perfglue/cpu_profiler.cc

index ea1be7e959596daa6321c98f527d0b621a08115c..81f2ccf8c9f664fa27ad3b250e3db8dff3c2fc20 100644 (file)
@@ -22,7 +22,7 @@
 void cpu_profiler_handle_command(const std::vector<std::string> &cmd,
                                 std::ostream& out)
 {
-  if (cmd[1] == "status") {
+  if (cmd.size() == 1 && cmd[0] == "status") {
     ProfilerState st;
     ProfilerGetCurrentState(&st);
     out << "cpu_profiler " << (st.enabled ? "enabled":"not enabled")
@@ -30,7 +30,7 @@ void cpu_profiler_handle_command(const std::vector<std::string> &cmd,
        << " profile_name " << st.profile_name
        << " samples " << st.samples_gathered;
   }
-  else if (cmd[1] == "flush") {
+  else if (cmd.size() == 1 && cmd[0] == "flush") {
     ProfilerFlush();
     out << "cpu_profiler: flushed";
   }