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

tarantool / tarantool / 12281896599

11 Dec 2024 05:41PM UTC coverage: 87.372% (+0.02%) from 87.355%
12281896599

Pull #10883

github

web-flow
Merge 1ffe9d3e4 into 4c302320c
Pull Request #10883: Suboptimal msgpuck support

69764 of 123664 branches covered (56.41%)

114 of 157 new or added lines in 5 files covered. (72.61%)

48 existing lines in 12 files now uncovered.

102736 of 117585 relevant lines covered (87.37%)

2941228.27 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,729,410✔
26
{
27
        if (!pthread_equal(pthread_self(), main_thread_id)) {
1,729,410!
UNCOV
28
                pthread_kill(main_thread_id, signum);
×
UNCOV
29
                return;
×
30
        }
31
        assert(sighandlers[signum] != NULL);
1,729,410!
32
        sighandlers[signum](signum);
1,729,410✔
33
}
34

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

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

47
        void (*old_handler)(int) = sighandlers[signum];
11,825✔
48
        if (sa->sa_handler == SIG_DFL || sa->sa_handler == SIG_IGN) {
11,825!
49
                sighandlers[signum] = NULL;
2✔
50
        } else {
51
                sighandlers[signum] = sa->sa_handler;
11,823✔
52
                sa->sa_handler = sighandler_dispatcher;
11,823✔
53
        }
54
        int rc = sigaction(signum, sa, osa);
11,825✔
55
        if (osa != NULL && old_handler != NULL)
11,825!
56
                osa->sa_handler = old_handler;
×
57
        return rc;
11,825✔
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