mirror of
https://github.com/nasa/trick.git
synced 2025-03-22 03:55:32 +00:00
tc_init is not thread-safe #289
Made the global sockaddr variables local and cleared them with a memset.
This commit is contained in:
parent
e3759ac594
commit
7d82690a0b
@ -18,7 +18,6 @@
|
||||
#include "dmtcpaware.h"
|
||||
#endif
|
||||
|
||||
static struct sockaddr_in s_in;
|
||||
|
||||
int tc_accept_(TCDevice * listen_device, TCDevice * device, const char *file, int line)
|
||||
{
|
||||
@ -31,7 +30,9 @@ int tc_accept_(TCDevice * listen_device, TCDevice * device, const char *file, in
|
||||
char *ptrL;
|
||||
char client_str[TC_TAG_LENGTH + 256];
|
||||
unsigned char byte_info[TC_BYTE_INFO_LENGTH];
|
||||
struct sockaddr_in s_in;
|
||||
|
||||
memset(&s_in, 0, sizeof(struct sockaddr_in)) ;
|
||||
/* Accept On Listen Device */
|
||||
length = sizeof(s_in);
|
||||
#if _DMTCP
|
||||
|
@ -19,7 +19,6 @@ int tc_init(TCDevice * listen_device) {
|
||||
return tc_init_with_connection_info( listen_device, TRICKCOMM_SOCKET_FAMILY, SOCK_STREAM, NULL, listen_device->port ) ;
|
||||
}
|
||||
|
||||
static struct sockaddr_in s_in;
|
||||
|
||||
int tc_init_with_connection_info( TCDevice * listen_device,
|
||||
int domain,
|
||||
@ -35,6 +34,9 @@ int tc_init_with_connection_info( TCDevice * listen_device,
|
||||
#ifdef __WIN32__
|
||||
WSADATA wsaData;
|
||||
#endif
|
||||
struct sockaddr_in s_in;
|
||||
|
||||
memset(&s_in, 0, sizeof(struct sockaddr_in)) ;
|
||||
|
||||
if (!listen_device) {
|
||||
TrickErrorHndlr *temp_error_hndlr = NULL;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "trick/tc_proto.h"
|
||||
#include "trick/trick_byteswap.h"
|
||||
|
||||
static struct sockaddr_in sockin;
|
||||
|
||||
int tc_init_udp_client(TCDevice * udp_client_device)
|
||||
{
|
||||
@ -33,6 +32,9 @@ int tc_init_udp_client(TCDevice * udp_client_device)
|
||||
int on = 1;
|
||||
struct hostent *h;
|
||||
int the_socket;
|
||||
struct sockaddr_in sockin;
|
||||
|
||||
memset(&sockin, 0 , sizeof(struct sockaddr_in)) ;
|
||||
|
||||
if (!udp_client_device) {
|
||||
trick_error_report(udp_client_device->error_handler,
|
||||
|
Loading…
x
Reference in New Issue
Block a user