<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p>Hi, Sergey!</p>
    <p>both issues were fixed and force-pushed to the branch.</p>
    <p>Sergey<br>
    </p>
    <div class="moz-cite-prefix">On 07.03.2025 10:21, Sergey Kaplun via
      Tarantool-patches wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:Z8qeiApzqTniyPpC@root">
      <pre wrap="" class="moz-quote-pre">Hi, Sergey!
Thanks for the fixes!
LGTM, with 2 minor comments below.

On 06.03.25, Sergey Bronnikov wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">When sysprof is not started the function `misc.sysprof.stop()`
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
Typo: s/started/started,/</pre>
    </blockquote>
    Fixed.<br>
    <blockquote type="cite" cite="mid:Z8qeiApzqTniyPpC@root">
      <pre wrap="" class="moz-quote-pre">

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">reports that the profiler is already running:

| $ ./src/luajit -e 'print(misc.sysprof.stop())'
| nil     profiler is running already     22

The patch fixes that:

| $ ./src/luajit -e 'print(misc.sysprof.stop())'
| nil     profiler is not running         22

Follows up tarantool/tarantool#781
---
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
<snipped>

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">+  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) {
+      lua_pushnil(L);
+      lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));
+      lua_pushinteger(L, EINVAL);
+      return 3;
+  }
   if (LJ_UNLIKELY(status != PROFILE_SUCCESS))
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
It looks like more natural now to use `else if` here now.</pre>
    </blockquote>
    <p>Fixed, updated version:</p>
    <p>--- a/src/lib_misc.c<br>
      +++ b/src/lib_misc.c<br>
      @@ -336,8 +336,14 @@ LJLIB_CF(misc_sysprof_stop)<br>
         return prof_error(L, PROFILE_ERRUSE, err_details);<br>
       #else<br>
         int status = luaM_sysprof_stop(L);<br>
      -  if (LJ_UNLIKELY(status != PROFILE_SUCCESS))<br>
      +  if (LJ_UNLIKELY(status == PROFILE_ERRRUN)) {<br>
      +    lua_pushnil(L);<br>
      +    lua_pushstring(L, err2msg(LJ_ERR_PROF_NOTRUNNING));<br>
      +    lua_pushinteger(L, EINVAL);<br>
      +    return 3;<br>
      +  } else if (LJ_UNLIKELY(status != PROFILE_SUCCESS)) {<br>
           return prof_error(L, status, NULL);<br>
      +  }<br>
       <br>
         lua_pushboolean(L, 1);<br>
         return 1;<br>
    </p>
    <blockquote type="cite" cite="mid:Z8qeiApzqTniyPpC@root">
      <pre wrap="" class="moz-quote-pre">

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">     return prof_error(L, status, NULL);
 
diff --git a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
index 91ea461b..f316c390 100644
--- a/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
+++ b/test/tarantool-tests/profilers/misclib-sysprof-lapi.test.lua
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
<snipped>

</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">-- 
2.43.0

</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>