Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
oai
freediameter
Commits
69ff4823
Commit
69ff4823
authored
Mar 08, 2010
by
Sebastien Decugis
Browse files
Remove dependency on signalent.h
parent
b5c7cd71
Changes
6
Hide whitespace changes
Inline
Side-by-side
contrib/signalent.h.sh
deleted
100755 → 0
View file @
b5c7cd71
#!/bin/bash
# The goal here is to regenerate a file signalent.h if it is missing. This file contains only a list of the signals abbreviations.
# This script needs to be improved...
cpp
-dM
/usr/include/signal.h
\
|
tr
-s
'\t '
' '
\
|
sed
's:#define \(SIG[A-Z]\+[0-9]*\) \([0-9]\+\):\2 \1:p;d'
\
|
sort
-n
--unique
freeDiameter/main.c
View file @
69ff4823
...
...
@@ -320,7 +320,7 @@ static void fd_shutdown(int signal)
{
TRACE_ENTRY
(
"%d"
,
signal
);
TRACE_DEBUG
(
INFO
,
"Received signal %s (%d), exiting"
,
SIGNALSTR
(
signal
),
signal
);
TRACE_DEBUG
(
INFO
,
"Received signal %s (%d), exiting"
,
fd_sig_abbrev
(
signal
),
signal
);
CHECK_FCT_DO
(
fd_event_send
(
fd_g_config
->
cnf_main_ev
,
FDEV_TERMINATE
,
0
,
NULL
),
exit
(
2
)
);
...
...
freeDiameter/tests/tests.h
View file @
69ff4823
...
...
@@ -56,6 +56,7 @@
#include <getopt.h>
#include <time.h>
#include <libgen.h>
#include <signal.h>
/* Define the return code values */
#define PASS 0
...
...
@@ -115,6 +116,11 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
parse_cmdline(argc, argv); \
}
static
void
test_timeout
(
int
signal
)
{
FAILTEST
(
"The timeout ("
_stringize
(
TEST_TIMEOUT
)
" sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute."
);
}
static
inline
void
parse_cmdline
(
int
argc
,
char
*
argv
[])
{
int
c
;
int
no_timeout
=
0
;
...
...
@@ -137,8 +143,10 @@ static inline void parse_cmdline(int argc, char * argv[]) {
}
}
fd_g_debug_lvl
=
(
test_verbo
>
0
)
?
(
test_verbo
-
1
)
:
0
;
if
(
!
no_timeout
)
if
(
!
no_timeout
)
{
alarm
(
TEST_TIMEOUT
);
fd_sig_register
(
SIGALRM
,
"Test.harness"
,
test_timeout
);
}
}
#endif
/* _TESTS_H */
include/freeDiameter/CMakeLists.txt
View file @
69ff4823
...
...
@@ -89,9 +89,6 @@ CHECK_SYMBOL_EXISTS(ntohll "" HAVE_NTOHLL)
# malloc.h ?
CHECK_INCLUDE_FILES
(
malloc.h HAVE_MALLOC_H
)
# signalent.h ? -- found in strace distrib; just for nice signal names...
CHECK_INCLUDE_FILES
(
signalent.h HAVE_SIGNALENT_H
)
# The default configuration file name
IF
(
NOT DEFAULT_CONF_FILE
)
SET
(
DEFAULT_CONF_FILE
"freeDiameter.conf"
)
...
...
include/freeDiameter/libfreeDiameter.h
View file @
69ff4823
...
...
@@ -589,13 +589,7 @@ int fd_sig_unregister(int signal);
void
fd_sig_dump
(
int
level
,
int
indent
);
/* Name of signals */
#ifdef HAVE_SIGNALENT_H
extern
const
char
*
const
fd_sig_str
[];
extern
const
int
fd_sig_nstr
;
# define SIGNALSTR(sig) (((sig) < fd_sig_nstr) ? fd_sig_str[(sig)] : "[unknown signal]")
#else
/* HAVE_SIGNALENT_H */
# define SIGNALSTR(sig) ("[no sig names]")
#endif
/* HAVE_SIGNALENT_H */
const
char
*
fd_sig_abbrev
(
int
signal
);
/*============================================================*/
...
...
libfreeDiameter/signal.c
View file @
69ff4823
...
...
@@ -37,14 +37,6 @@
#include <signal.h>
/* List of signal names */
#ifdef HAVE_SIGNALENT_H
const
char
*
const
fd_sig_str
[]
=
{
# include "signalent.h"
};
const
int
fd_sig_nstr
=
sizeof
fd_sig_str
/
sizeof
fd_sig_str
[
0
];
#endif
/* HAVE_SIGNALENT_H */
/* A structure to hold the registered signal handlers */
struct
sig_hdl
{
struct
fd_list
chain
;
/* Link in the sig_hdl_list ordered by signal */
...
...
@@ -64,6 +56,9 @@ static pthread_attr_t detached;
/* Note if the module was initialized */
static
int
sig_initialized
=
0
;
/* signals short names list */
static
int
abbrevs_init
(
void
);
/* Initialize the support for signals */
int
fd_sig_init
(
void
)
{
...
...
@@ -74,6 +69,9 @@ int fd_sig_init(void)
if
(
sig_initialized
)
return
0
;
/* Initialize the list of abbreviations */
CHECK_FCT
(
abbrevs_init
());
/* Block all signals from the current thread and all its future children, so that signals are delivered only to our sig_hdl->sig_thr */
sigfillset
(
&
sig_all
);
CHECK_POSIX
(
pthread_sigmask
(
SIG_BLOCK
,
&
sig_all
,
NULL
)
);
...
...
@@ -96,7 +94,7 @@ static void * signal_caller(void * arg)
char
buf
[
40
];
/* Name this thread */
snprintf
(
buf
,
sizeof
(
buf
),
"cb %d:%s:%s"
,
me
->
signal
,
SIGNALSTR
(
me
->
signal
),
me
->
modname
);
snprintf
(
buf
,
sizeof
(
buf
),
"cb %d:%s:%s"
,
me
->
signal
,
fd_sig_abbrev
(
me
->
signal
),
me
->
modname
);
fd_log_threadname
(
buf
);
TRACE_ENTRY
(
"%p"
,
me
);
...
...
@@ -120,7 +118,7 @@ static void * signal_catcher(void * arg)
ASSERT
(
arg
);
/* Name this thread */
snprintf
(
buf
,
sizeof
(
buf
),
"catch %d:%s:%s"
,
me
->
signal
,
SIGNALSTR
(
me
->
signal
),
me
->
modname
);
snprintf
(
buf
,
sizeof
(
buf
),
"catch %d:%s:%s"
,
me
->
signal
,
fd_sig_abbrev
(
me
->
signal
),
me
->
modname
);
fd_log_threadname
(
buf
);
TRACE_ENTRY
(
"%p"
,
me
);
...
...
@@ -143,7 +141,7 @@ static void * signal_catcher(void * arg)
}
/* An error occurred... What should we do ? */
TRACE_DEBUG
(
INFO
,
"!!! ERROR !!! The signal catcher for %d:%s:%s is terminating!"
,
me
->
signal
,
SIGNALSTR
(
me
->
signal
),
me
->
modname
);
TRACE_DEBUG
(
INFO
,
"!!! ERROR !!! The signal catcher for %d:%s:%s is terminating!"
,
me
->
signal
,
fd_sig_abbrev
(
me
->
signal
),
me
->
modname
);
/* Better way to handle this ? */
ASSERT
(
0
);
...
...
@@ -179,7 +177,7 @@ int fd_sig_register(int signal, char * modname, void (*handler)(int signal))
continue
;
if
(
nh
->
signal
==
signal
)
{
matched
=
1
;
TRACE_DEBUG
(
INFO
,
"Signal %d (%s) is already registered by module '%s'"
,
signal
,
SIGNALSTR
(
signal
),
nh
->
modname
);
TRACE_DEBUG
(
INFO
,
"Signal %d (%s) is already registered by module '%s'"
,
signal
,
fd_sig_abbrev
(
signal
),
nh
->
modname
);
}
break
;
}
...
...
@@ -215,7 +213,7 @@ void fd_sig_dump(int level, int indent)
for
(
li
=
sig_hdl_list
.
next
;
li
!=
&
sig_hdl_list
;
li
=
li
->
next
)
{
struct
sig_hdl
*
h
=
(
struct
sig_hdl
*
)
li
;
fd_log_debug
(
"%*s - sig %*d (%s) => %p in module %s
\n
"
,
indent
,
""
,
2
,
h
->
signal
,
SIGNALSTR
(
h
->
signal
),
h
->
sig_hdl
,
h
->
modname
);
fd_log_debug
(
"%*s - sig %*d (%s) => %p in module %s
\n
"
,
indent
,
""
,
2
,
h
->
signal
,
fd_sig_abbrev
(
h
->
signal
),
h
->
sig_hdl
,
h
->
modname
);
}
CHECK_POSIX_DO
(
pthread_mutex_unlock
(
&
sig_hdl_lock
),
/* continue */
);
...
...
@@ -288,3 +286,171 @@ void fd_sig_fini(void)
CHECK_POSIX_DO
(
pthread_attr_destroy
(
&
detached
),
/* continue */
);
return
;
}
/**************************************************************************************/
static
char
**
abbrevs
;
static
size_t
abbrevs_nr
=
0
;
/* Initialize the array of signals */
static
int
abbrevs_init
(
void
)
{
int
i
;
#define SIGNAL_MAX_LIMIT 100
/* Do not save signals with value > this */
/* The raw list of signals in the system -- might be incomplete, add any signal you need */
struct
sig_abb_raw
{
int
sig
;
char
*
name
;
}
abbrevs_raw
[]
=
{
{
0
,
"[unknown signal]"
}
#define RAW_SIGNAL( _sig ) ,{ _sig, #_sig }
#ifdef SIGBUS
RAW_SIGNAL
(
SIGBUS
)
#endif
/* SIGBUS */
#ifdef SIGTTIN
RAW_SIGNAL
(
SIGTTIN
)
#endif
/* SIGTTIN */
#ifdef SIGTTOU
RAW_SIGNAL
(
SIGTTOU
)
#endif
/* SIGTTOU */
#ifdef SIGPROF
RAW_SIGNAL
(
SIGPROF
)
#endif
/* SIGPROF */
#ifdef SIGALRM
RAW_SIGNAL
(
SIGALRM
)
#endif
/* SIGALRM */
#ifdef SIGFPE
RAW_SIGNAL
(
SIGFPE
)
#endif
/* SIGFPE */
#ifdef SIGSTKFLT
RAW_SIGNAL
(
SIGSTKFLT
)
#endif
/* SIGSTKFLT */
#ifdef SIGSTKSZ
RAW_SIGNAL
(
SIGSTKSZ
)
#endif
/* SIGSTKSZ */
#ifdef SIGUSR1
RAW_SIGNAL
(
SIGUSR1
)
#endif
/* SIGUSR1 */
#ifdef SIGURG
RAW_SIGNAL
(
SIGURG
)
#endif
/* SIGURG */
#ifdef SIGIO
RAW_SIGNAL
(
SIGIO
)
#endif
/* SIGIO */
#ifdef SIGQUIT
RAW_SIGNAL
(
SIGQUIT
)
#endif
/* SIGQUIT */
#ifdef SIGABRT
RAW_SIGNAL
(
SIGABRT
)
#endif
/* SIGABRT */
#ifdef SIGTRAP
RAW_SIGNAL
(
SIGTRAP
)
#endif
/* SIGTRAP */
#ifdef SIGVTALRM
RAW_SIGNAL
(
SIGVTALRM
)
#endif
/* SIGVTALRM */
#ifdef SIGSEGV
RAW_SIGNAL
(
SIGSEGV
)
#endif
/* SIGSEGV */
#ifdef SIGCONT
RAW_SIGNAL
(
SIGCONT
)
#endif
/* SIGCONT */
#ifdef SIGPIPE
RAW_SIGNAL
(
SIGPIPE
)
#endif
/* SIGPIPE */
#ifdef SIGWINCH
RAW_SIGNAL
(
SIGWINCH
)
#endif
/* SIGWINCH */
#ifdef SIGXFSZ
RAW_SIGNAL
(
SIGXFSZ
)
#endif
/* SIGXFSZ */
#ifdef SIGHUP
RAW_SIGNAL
(
SIGHUP
)
#endif
/* SIGHUP */
#ifdef SIGCHLD
RAW_SIGNAL
(
SIGCHLD
)
#endif
/* SIGCHLD */
#ifdef SIGSYS
RAW_SIGNAL
(
SIGSYS
)
#endif
/* SIGSYS */
#ifdef SIGSTOP
RAW_SIGNAL
(
SIGSTOP
)
#endif
/* SIGSTOP */
#ifdef SIGUSR2
RAW_SIGNAL
(
SIGUSR2
)
#endif
/* SIGUSR2 */
#ifdef SIGTSTP
RAW_SIGNAL
(
SIGTSTP
)
#endif
/* SIGTSTP */
#ifdef SIGKILL
RAW_SIGNAL
(
SIGKILL
)
#endif
/* SIGKILL */
#ifdef SIGXCPU
RAW_SIGNAL
(
SIGXCPU
)
#endif
/* SIGXCPU */
#ifdef SIGUNUSED
RAW_SIGNAL
(
SIGUNUSED
)
#endif
/* SIGUNUSED */
#ifdef SIGPWR
RAW_SIGNAL
(
SIGPWR
)
#endif
/* SIGPWR */
#ifdef SIGILL
RAW_SIGNAL
(
SIGILL
)
#endif
/* SIGILL */
#ifdef SIGINT
RAW_SIGNAL
(
SIGINT
)
#endif
/* SIGINT */
#ifdef SIGIOT
RAW_SIGNAL
(
SIGIOT
)
#endif
/* SIGIOT */
#ifdef SIGTERM
RAW_SIGNAL
(
SIGTERM
)
#endif
/* SIGTERM */
};
TRACE_ENTRY
(
""
);
/* First pass: find the highest signal number */
for
(
i
=
0
;
i
<
sizeof
(
abbrevs_raw
)
/
sizeof
(
abbrevs_raw
[
0
]);
i
++
)
{
if
(
abbrevs_raw
[
i
].
sig
>
SIGNAL_MAX_LIMIT
)
{
TRACE_DEBUG
(
ANNOYING
,
"Ignoring signal %s (%d), increase SIGNAL_MAX_LIMIT if you want it included"
,
abbrevs_raw
[
i
].
name
,
abbrevs_raw
[
i
].
sig
);
continue
;
}
if
(
abbrevs_raw
[
i
].
sig
>
abbrevs_nr
)
abbrevs_nr
=
abbrevs_raw
[
i
].
sig
;
}
/* Now, alloc the array */
abbrevs_nr
++
;
/* 0-based */
CHECK_MALLOC
(
abbrevs
=
calloc
(
abbrevs_nr
,
sizeof
(
char
*
)
)
);
/* Second pass: add all the signals in the array */
for
(
i
=
0
;
i
<
sizeof
(
abbrevs_raw
)
/
sizeof
(
abbrevs_raw
[
0
]);
i
++
)
{
if
(
abbrevs_raw
[
i
].
sig
>
SIGNAL_MAX_LIMIT
)
continue
;
if
(
abbrevs
[
abbrevs_raw
[
i
].
sig
]
==
NULL
)
abbrevs
[
abbrevs_raw
[
i
].
sig
]
=
abbrevs_raw
[
i
].
name
;
}
/* Third pass: Set all missing signals to the undef value */
for
(
i
=
0
;
i
<
abbrevs_nr
;
i
++
)
{
if
(
abbrevs
[
i
]
==
NULL
)
abbrevs
[
i
]
=
abbrevs_raw
[
0
].
name
;
}
/* Done! */
return
0
;
}
/* Names of signals */
const
char
*
fd_sig_abbrev
(
int
signal
)
{
if
(
signal
<
abbrevs_nr
)
return
abbrevs
[
signal
];
return
abbrevs
[
0
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment