Skip to content

Commit b023d85

Browse files
authored
Updated to only call async-signal-safe calls after monte slave fork. (#1987)
* Updated to only call async-signal-safe calls after monte slave fork, and made mimimal changes to enable building test_programs in trick_utils/comm.. * Reverted changes for using async-signal-safe calls, instead updated so vs init happens after master/slave logic for monte carlo. * Updated the initialization job of vs init to P2 for JSONVariableServerSimObject to be consistent with VariableServerSimObject.
1 parent 15293c7 commit b023d85

File tree

7 files changed

+51
-37
lines changed

7 files changed

+51
-37
lines changed

share/trick/sim_objects/default_trick_sys.sm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,9 @@ class VariableServerSimObject : public Trick::SimObject {
466466
// Call variable server initialization for normal sims,
467467
// monte carlo slave sim children, and the monte carlo master.
468468
// monte carlo slave parents do not reach initialization.
469-
{TRK} P0 ("initialization") trick_ret = vs.init() ;
469+
// Note: schedule this after MonteCarlo::execute_monte (which is P1)
470+
// so Monte Carlo slave parents do not reach initialization.
471+
{TRK} P2 ("initialization") trick_ret = vs.init() ;
470472

471473
#ifndef TRICK_NO_MONTE_CARLO
472474
{TRK} ("monte_master_init") trick_ret = vs.init() ;
@@ -514,7 +516,10 @@ class JSONVariableServerSimObject : public Trick::SimObject {
514516
JSONVariableServerSimObject() {
515517

516518
{TRK} ("default_data") vs.init_listen_device() ;
517-
{TRK} P0 ("initialization") trick_ret = vs.init() ;
519+
// Schedule JSON VS initialization after MonteCarlo::execute_monte (P1)
520+
// to be consistent with VariableServerSimObject so that Monte Carlo
521+
// slave parents do not reach initialization if Monte Carlo is enabled.
522+
{TRK} P2 ("initialization") trick_ret = vs.init() ;
518523
{TRK} ("restart") vs.restart();
519524
{TRK} ("shutdown") vs.cancel_thread() ;
520525

trick_source/trick_utils/comm/test_programs/dr_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*/
1919

20-
#include "../include/tc_proto.h"
20+
#include "trick/tc_proto.h"
2121

2222
#define MAX_FILES 128
2323
typedef struct {

trick_source/trick_utils/comm/test_programs/makefile

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
# Date: 6/19/00
1010
#####################################################################
1111

12-
-include ${TRICK_HOME}/makefiles/Makefile.common
12+
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
13+
include ${TRICK_HOME}/share/trick/makefiles/Makefile.tricklib
1314

1415
ifndef TRICK_HOST_CPU
1516
TRICK_HOST_CPU := $(shell trick-gte TRICK_HOST_CPU)
@@ -21,7 +22,8 @@ endif
2122

2223

2324
CC = cc
24-
FLAGS =
25+
# Default include paths for test builds (can be overridden by environment)
26+
FLAGS ?= -I${TRICK_HOME}/trick_source -I${TRICK_HOME}/include
2527
ifeq ($(TRICK_HOST_TYPE), Darwin)
2628
LIBS =
2729
else
@@ -36,10 +38,8 @@ endif
3638
## UTILITY DEFINITIONS ##
3739
#####################################################################
3840

39-
LIB_DIR = ../object_$(shell uname -s)
40-
COMM_LIB = ${LIB_DIR}/libtrick_comm.a
41-
STUBS_LIB = ${LIB_DIR}/libtrick_stubs.a
42-
LIBTC_LIB = $(COMM_LIB) $(STUBS_LIB) -lpthread ${LIBS}
41+
COMM_LIB = ${TRICK_LIB_DIR}/libtrick_comm.a
42+
LIBTC_LIB = $(COMM_LIB) -lpthread ${LIBS}
4343

4444

4545
#####################################################################
@@ -62,9 +62,9 @@ TEST_PRGMS = \
6262
default:
6363
@ if [ "${TRICK_HOME}" != "" ] ; then \
6464
if [ "`uname -s`" = "SunOS" ] ; then \
65-
make -e test "FLAGS=-I${TRICK_HOME}/trick_source -I../include" "LIBS=-lsocket -lnsl" ; \
65+
make -e test "FLAGS=$(FLAGS)" "LIBS=-lsocket -lnsl" ; \
6666
else \
67-
make -e test "FLAGS=-I${TRICK_HOME}/trick_source -I../include" "LIBS=${LIBS}" ; \
67+
make -e test "FLAGS=$(FLAGS)" "LIBS=${LIBS}" ; \
6868
fi \
6969
else \
7070
if [ "`uname -s`" = "SunOS" ] ; then \
@@ -105,19 +105,11 @@ $(OBJ_DIR)/dr_client: dr_client.c
105105
$(CC) $(FLAGS) -o $@ ${@F}.c $(LIBTC_LIB)
106106

107107
$(COMM_LIB):
108-
@ cd .. ; make STAND_ALONE=1 trick_comm
109-
110-
$(STUBS_LIB):
111-
@ cd .. ; make STAND_ALONE=1 trick_stubs_lib
112-
108+
@echo "Building parent comm library: invoking parent 'trick' target..."
109+
@cd .. && $(MAKE) trick
113110

114111
$(OBJ_DIR)/dr_client: $(COMM_LIB)
115-
$(OBJ_DIR)/dr_client: $(STUBS_LIB)
116112
$(OBJ_DIR)/tc_server: $(COMM_LIB)
117-
$(OBJ_DIR)/tc_server: $(STUBS_LIB)
118113
$(OBJ_DIR)/tc_client: $(COMM_LIB)
119-
$(OBJ_DIR)/tc_client: $(STUBS_LIB)
120114
$(OBJ_DIR)/tc_multi_serv_example: $(COMM_LIB)
121115
$(OBJ_DIR)/tc_multi_client_example: $(COMM_LIB)
122-
$(OBJ_DIR)/tc_multi_serv_example: $(STUBS_LIB)
123-
$(OBJ_DIR)/tc_multi_client_example: $(STUBS_LIB)

trick_source/trick_utils/comm/test_programs/tc_client.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
#include "../include/tc_proto.h"
1+
#include "trick/tc_proto.h"
32

43
int main( int narg, char** args ) {
54

trick_source/trick_utils/comm/test_programs/tc_multi_client_example.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* This program uses trickcomm "tc" routines to create a client that
55
* connects to a server and writes and reads 10 messages.
66
*/
7+
#include "trick/tc_proto.h"
78

8-
#include "../include/tc_proto.h"
9-
#include <string.h>
9+
#include <signal.h>
10+
#include <unistd.h>
1011

1112
void sigint_hndlr( int sig );
1213
void stupid( int sig );

trick_source/trick_utils/comm/test_programs/tc_multi_serv_example.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
* connects to a server and writes and reads 10 messages.
66
*/
77

8+
#include "trick/bitfield_proto.h"
9+
#include "trick/tc_proto.h"
810

9-
#include "../include/attributes.h"
10-
#include "../include/tc_proto.h"
11-
#include <string.h>
11+
#include <pthread.h>
12+
#include <signal.h>
13+
#include <unistd.h>
1214

1315

1416
void sigint_hndlr( int sig );
@@ -45,63 +47,78 @@ typedef struct {
4547
ATTRIBUTES attrBUFFER[] = {
4648
{ "i1", "int", "--", "",
4749
"Not Specified",
50+
"",
4851
3,5,sizeof(int),0,0,Language_C,0,
4952
0,(char*)0, 0 } ,
5053
{ "s1", "short", "--", "",
5154
"Not Specified",
55+
"",
5256
3,3,sizeof(short),0,0,Language_C,0,
5357
0,(char*)0, 0 } ,
5458
{ "s2", "short", "--", "",
5559
"Not Specified",
60+
"",
5661
3,3,sizeof(short),0,0,Language_C,0,
5762
0,(char*)0, 0 } ,
5863
{ "c1", "char", "--", "",
5964
"Not Specified",
65+
"",
6066
3,0,sizeof(char),0,0,Language_C,0,
6167
0,(char*)0, 0 } ,
6268
{ "c2", "char", "--", "",
6369
"Not Specified",
70+
"",
6471
3,0,sizeof(char),0,0,Language_C,0,
6572
0,(char*)0, 0 } ,
6673
{ "c3", "char", "--", "",
6774
"Not Specified",
75+
"",
6876
3,0,sizeof(char),0,0,Language_C,0,
6977
0,(char*)0, 0 } ,
7078
{ "c4", "char", "--", "",
7179
"Not Specified",
80+
"",
7281
3,0,sizeof(char),0,0,Language_C,0,
7382
0,(char*)0, 0 } ,
7483
{ "f1", "float", "--", "",
7584
"Not Specified",
85+
"",
7686
3,9,sizeof(float),0,0,Language_C,0,
7787
0,(char*)0, 0 } ,
7888
{ "b1", "int", "--", "",
7989
"Not Specified",
80-
3,11,0,0,0,Language_C,0,
90+
"",
91+
3,11,0,0,0,Language_C,0,
8192
0,(char*)0, 0,{{5,27}} } ,
8293
{ "b2", "int", "--", "",
8394
"Not Specified",
84-
3,11,0,0,0,Language_C,0,
95+
"",
96+
3,11,0,0,0,Language_C,0,
8597
0,(char*)0, 0,{{4,23}} } ,
8698
{ "b3", "int", "--", "",
8799
"Not Specified",
88-
3,11,0,0,0,Language_C,0,
100+
"",
101+
3,11,0,0,0,Language_C,0,
89102
0,(char*)0, 0,{{7,16}} } ,
90103
{ "b4", "int", "--", "",
91104
"Not Specified",
92-
3,11,0,0,0,Language_C,0,
105+
"",
106+
3,11,0,0,0,Language_C,0,
93107
0,(char*)0, 0,{{13,3}} } ,
94108
{ "b5", "int", "--", "",
95109
"Not Specified",
96-
3,11,0,0,0,Language_C,0,
110+
"",
111+
3,11,0,0,0,Language_C,0,
97112
0,(char*)0, 0,{{3,0}} } ,
98113
{ "i2", "int", "--", "",
99114
"Not Specified",
100-
3,5,sizeof(int),0,0,Language_C,0,
115+
"",
116+
3,5,sizeof(int),0,0,Language_C,0,
101117
0,(char*)0, 0 } ,
102118
{ "d1", "double", "--", "",
103119
"Not Specified",
104-
3,10,sizeof(double),0,0,Language_C,0,
120+
"",
121+
3,10,sizeof(double),0,0,Language_C,0,
105122
0,(char*)0, 0 } ,
106123
{ "" }
107124
} ;
@@ -140,7 +157,7 @@ void *continuous_connect(void *in) {
140157
TCDevice* temp_device ;
141158
int status ;
142159

143-
fprintf(stderr,"Starting continuous_connect %d\n", pthread_self());
160+
fprintf(stderr,"Starting continuous_connect %lu\n", (unsigned long)pthread_self());
144161
/* continuously look for and connect to new clients */
145162
while (1) {
146163
temp_device = malloc(sizeof(TCDevice));

trick_source/trick_utils/comm/test_programs/tc_server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
#include "trick/tc_proto.h"
12

2-
#include "../include/tc_proto.h"
33
#ifndef __WIN32__
44
#include <sys/time.h>
55
#endif

0 commit comments

Comments
 (0)