diff options
Diffstat (limited to 'src/Startup.c')
-rw-r--r-- | src/Startup.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/Startup.c b/src/Startup.c index 4bed822..1ad4f7c 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -19,10 +19,6 @@ #include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "ioStreamedHDF5GH.h" -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - /* the rcs ID and its dummy function to use it */ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusPUGHIO_IOStreamedHDF5_Startup_c) @@ -88,13 +84,13 @@ void IOStreamedHDF5_Terminate (const cGH *GH) if (myGH) { /* close the data and checkpoint output sockets */ - if (myGH->data_socket >= 0) + if (myGH->data_socket != INVALID_SOCKET) { - close (myGH->data_socket); + Socket_CloseSocket (myGH->data_socket); } - if (myGH->checkpoint_socket >= 0) + if (myGH->checkpoint_socket != INVALID_SOCKET) { - close (myGH->checkpoint_socket); + Socket_CloseSocket (myGH->checkpoint_socket); } /* release allocated timers */ @@ -132,7 +128,7 @@ void IOStreamedHDF5_Terminate (const cGH *GH) CCTK_RegisterIOMethodOutputVarAs CCTK_RegisterIOMethodTimeToOutput CCTK_RegisterIOMethodTriggerOutput - Socket_TCPOpenServerSock + Socket_TCPOpenServerSocket Socket_SetNonBlocking IOUtil_AdvertiseFile Util_GetHostName @@ -207,12 +203,13 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) } /* only processor 0 is doing socket I/O */ - myGH->data_socket = -1; + myGH->data_socket = INVALID_SOCKET; myproc = CCTK_MyProc (GH); if (myproc == 0) { - myGH->data_socket = Socket_TCPOpenServerSock (data_port); - if (myGH->data_socket < 0) + myGH->data_socket = + Socket_TCPOpenServerSocket (data_port, &myGH->data_port, 1); + if (myGH->data_socket == INVALID_SOCKET) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Couldn't open TCP server socket on output port %d. " @@ -222,16 +219,16 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { CCTK_WARN (1, "Couldn't set output socket into non-blocking mode. " "No HDF5 streaming output will be available !"); - close (myGH->data_socket); - myGH->data_socket = -1; + Socket_CloseSocket (myGH->data_socket); + myGH->data_socket = INVALID_SOCKET; } else { Util_GetHostName (hostname, sizeof (hostname)); CCTK_VInfo (CCTK_THORNSTRING, "HDF5 data streaming service started on\n" - " %s:%d", - hostname, data_port); + " %s:%u", + hostname, myGH->data_port); /* write the hostname/portnumber information in a temporary file which gets advertised and then can be downloaded */ @@ -299,12 +296,13 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) } /* only processor 0 is doing socket I/O */ - myGH->checkpoint_socket = -1; + myGH->checkpoint_socket = INVALID_SOCKET; myGH->checkpoint_fapl = -1; if (myproc == 0) { - myGH->checkpoint_socket = Socket_TCPOpenServerSock (checkpoint_port); - if (myGH->checkpoint_socket < 0) + myGH->checkpoint_socket = + Socket_TCPOpenServerSocket (checkpoint_port, &myGH->checkpoint_port, 1); + if (myGH->checkpoint_socket == INVALID_SOCKET) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Couldn't open TCP server socket on checkpoint port %d. " @@ -315,8 +313,8 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { CCTK_WARN (1, "Couldn't set checkpoint socket into non-blocking mode. " "No IOStreamedHDF5 checkpointing will be available !"); - close (myGH->checkpoint_socket); - myGH->checkpoint_socket = -1; + Socket_CloseSocket (myGH->checkpoint_socket); + myGH->checkpoint_socket = INVALID_SOCKET; } else { @@ -333,8 +331,8 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) Util_GetHostName (hostname, sizeof (hostname)); CCTK_VInfo (CCTK_THORNSTRING, "HDF5 checkpoint streaming service started on\n" - " %s:%d", - hostname, checkpoint_port); + " %s:%u", + hostname, myGH->checkpoint_port); } } |