Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
f0347f53
Commit
f0347f53
authored
Jun 10, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle signals differently in order to debug the issue with empty outputs
parent
a0727bde
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
15 deletions
+54
-15
packet-exchange/src/client.c
packet-exchange/src/client.c
+6
-7
packet-exchange/src/server.c
packet-exchange/src/server.c
+7
-8
packet-exchange/src/utilities.c
packet-exchange/src/utilities.c
+35
-0
packet-exchange/src/utilities.h
packet-exchange/src/utilities.h
+6
-0
No files found.
packet-exchange/src/client.c
View file @
f0347f53
...
...
@@ -56,7 +56,7 @@ typedef struct network_config {
static
void
process_options
(
int
argc
,
char
*
argv
[]);
static
void
do_tsn_task
(
struct
thread_param
*
param
,
char
*
data
,
uint64_t
next_txtime
);
static
void
print_histograms
();
static
void
sig
int_handler
(
int
sig_num
);
static
void
sig
hand
(
int
sig_num
);
// Static variables
...
...
@@ -160,9 +160,6 @@ int main(int argc, char *argv[]) {
pthread_t
thread
;
thread_stat_t
*
stats
;
// Catch breaks with sigint_handler
signal
(
SIGINT
,
sigint_handler
);
param
=
malloc
(
sizeof
(
thread_param_t
));
stats
=
&
param
->
stats
;
...
...
@@ -191,6 +188,9 @@ int main(int argc, char *argv[]) {
memset
((
int64_t
*
)
histograms
,
0
,
NB_HISTOGRAMS
*
MAX_HIST_VAL
);
}
// Catch breaks with sighand to print the histograms
init_signals
(
sighand
,
enable_histograms
);
// Initialize the UDP packet sending socket
init_udp_send
(
enable_etf
,
enable_timestamps
,
network_config
.
packet_priority
,
...
...
@@ -328,9 +328,8 @@ static void print_histograms() {
printf
(
"]}]}
\n
"
);
}
static
void
sig
int_handler
(
int
sig_num
)
{
static
void
sig
hand
(
int
sig_num
)
{
(
void
)
sig_num
;
if
(
enable_histograms
)
print_histograms
();
exit
(
EXIT_SUCCESS
);
}
...
...
packet-exchange/src/server.c
View file @
f0347f53
...
...
@@ -60,7 +60,7 @@ typedef struct main_param {
static
void
process_options
(
int
argc
,
char
*
argv
[]);
static
void
print_histograms
();
static
void
sig
int_handler
(
int
sig_num
);
static
void
sig
hand
(
int
sig_num
);
// Static variables
...
...
@@ -81,6 +81,7 @@ static enum TSNTask tsn_task;
struct
timespec
measures_start
;
struct
timespec
measures_end
;
static
void
help
(
char
*
argv
[])
{
printf
(
"Usage: %s [-aghtv] [-b CLIENT_IP] [-d BUF_LEN] [-f IF] [-i USEC] [-p PRIO] [-r USEC]
\n\n
"
,
argv
[
0
]);
printf
(
" -a Run the real time thread on CPU1
\n
"
);
...
...
@@ -182,9 +183,6 @@ int main(int argc, char *argv[]) {
thread_stat_t
*
stats
;
int64_t
diff
;
// Catch breaks with sigint_handler
signal
(
SIGINT
,
sigint_handler
);
param
=
malloc
(
sizeof
(
thread_param_t
));
stats
=
&
param
->
stats
;
...
...
@@ -210,6 +208,9 @@ int main(int argc, char *argv[]) {
memset
((
int64_t
*
)
histograms
,
0
,
NB_HISTOGRAMS
*
MAX_HIST_VAL
);
}
// Catch breaks with sighand to print the histograms
init_signals
(
sighand
,
enable_histograms
);
// Initialize the UDP packet receiving socket
init_udp_recv
(
enable_timestamps
,
network_config
.
network_if
);
...
...
@@ -324,11 +325,9 @@ static void print_histograms() {
printf
(
"]]}]}
\n
"
);
}
static
void
sigint_handler
(
int
sig_num
)
{
static
void
sighand
(
int
sig_num
)
{
(
void
)
sig_num
;
if
(
enable_histograms
)
print_histograms
();
if
(
param
->
stats
.
lost_packets
)
...
...
packet-exchange/src/utilities.c
View file @
f0347f53
#define _GNU_SOURCE
#include <inttypes.h>
#include <stdint.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include "utilities.h"
(
void
)(
*
previous_handlers
[
NSIG
])(
int
);
static
(
void
)(
*
sighand
)(
int
);
uint64_t
ts_to_uint
(
struct
timespec
t
)
{
return
t
.
tv_sec
*
NSEC_PER_SEC
+
t
.
tv_nsec
;
}
...
...
@@ -28,3 +32,34 @@ uint64_t calcdiff_ns(struct timespec t1, struct timespec t2) {
uint64_t
max
(
uint64_t
a
,
uint64_t
b
)
{
return
a
>
b
?
a
:
b
;
}
uint64_t
min
(
uint64_t
a
,
uint64_t
b
)
{
return
a
<
b
?
a
:
b
;
}
static
void
sighand_wrapper
(
int
sig
)
{
// If we get un unexpected signal, report it, if not print the histogram
if
(
sig
==
SIGINT
||
sig
==
SIGTERM
)
(
*
sighand
)(
sig
);
// Will print the histogram
else
printf
(
"Uknown signal interrupt: %s (%d)
\n
"
,
strsignal
(
sig
),
sig
);
// Execute the default handler
if
(
previous_handlers
[
sig
]
==
SIG_DFL
)
{
signal
(
sig
,
SIG_DFL
);
raise
(
sig
);
}
else
if
(
previous_handlers
[
sig
]
==
SIG_IGN
)
{
return
;
}
else
{
(
*
previous_handlers
[
sig
])(
sig
);
}
}
void
init_signals
((
void
)(
*
_sighand
(
int
)),
int
enable_histograms
)
{
sighand
=
_sighand
;
if
(
enable_histograms
)
for
(
int
i
=
0
;
i
<
NSIG
;
i
++
)
signal
(
i
,
sighand_wrapper
);
}
packet-exchange/src/utilities.h
View file @
f0347f53
...
...
@@ -4,6 +4,7 @@
#define _GNU_SOURCE
#include <inttypes.h>
#include <stdint.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
...
...
@@ -27,4 +28,9 @@ uint64_t calcdiff_ns(struct timespec t1, struct timespec t2);
uint64_t
max
(
uint64_t
a
,
uint64_t
b
);
uint64_t
min
(
uint64_t
a
,
uint64_t
b
);
void
init_signals
((
void
)(
*
_sighand
(
int
)),
int
enable_histograms
);
extern
(
void
)(
*
previous_handlers
[
NSIG
])(
int
);
#endif
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