• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / tarantool / 11612287117

31 Oct 2024 12:54PM CUT coverage: 87.269% (-0.007%) from 87.276%
11612287117

push

github

sergepetrenko
perf: introduce perf test for luafun

When fixing `drop_while` function in `luafun` submodule, we wrote a
benchmark to choose the most efficient solution - let's put it to our
perf test suite. The commit creates a new perf test for `luafun` module
and puts there above-mentioned benchmark.

NO_TEST=perftest
NO_CHANGELOG=perftest
NO_DOC=perftest

(cherry picked from commit 6ae595f5d)

68522 of 121744 branches covered (56.28%)

101129 of 115882 relevant lines covered (87.27%)

2507771.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/lib/core/tt_sigaction.c
1
/*
2
 * SPDX-License-Identifier: BSD-2-Clause
3
 *
4
 * Copyright 2010-2022, Tarantool AUTHORS, please see AUTHORS file.
5
 */
6
#include <assert.h>
7
#include <pthread.h>
8
#include <stdbool.h>
9
#include "tt_sigaction.h"
10

11
#define SIGMAX 32
12

13
/** Flag is set if main_thread_id variable is initialized. */
14
static bool main_thread_initialized;
15
/** Main thread id, it is set on first tt_sigaction call. */
16
static pthread_t main_thread_id;
17

18
static void (*sighandlers[SIGMAX])(int signum);
19

20
/**
21
 * Check that signal has been delivered to the main thread
22
 * and call signal handler or redirect it if thread is not main.
23
 */
24
static void
25
sighandler_dispatcher(int signum)
1,201,630✔
26
{
27
        if (!pthread_equal(pthread_self(), main_thread_id)) {
1,201,630!
28
                pthread_kill(main_thread_id, signum);
×
29
                return;
×
30
        }
31
        assert(sighandlers[signum] != NULL);
1,201,630!
32
        sighandlers[signum](signum);
1,201,630✔
33
}
34

35
int
36
tt_sigaction(int signum, struct sigaction *sa, struct sigaction *osa)
10,729✔
37
{
38
        assert(signum < SIGMAX);
10,729!
39
        assert(sa != NULL);
10,729!
40

41
        /* Memorize id of main thread at the first call. */
42
        if (!main_thread_initialized) {
10,729✔
43
                main_thread_id = pthread_self();
5,364✔
44
                main_thread_initialized = true;
5,364✔
45
        }
46

47
        void (*old_handler)(int) = sighandlers[signum];
10,729✔
48
        if (sa->sa_handler == SIG_DFL || sa->sa_handler == SIG_IGN) {
10,729!
49
                sighandlers[signum] = NULL;
2✔
50
        } else {
51
                sighandlers[signum] = sa->sa_handler;
10,727✔
52
                sa->sa_handler = sighandler_dispatcher;
10,727✔
53
        }
54
        int rc = sigaction(signum, sa, osa);
10,729✔
55
        if (osa != NULL && old_handler != NULL)
10,729!
56
                osa->sa_handler = old_handler;
×
57
        return rc;
10,729✔
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc