From 82c17d742b4f5e237725e271e86da7a396d86270 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 14 May 2002 19:19:08 +0000 Subject: Routines from thorn Socket slighly changed. Added port hunting for IOStreamedHDF5. You must also update thorn CactusConnect/Socket now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@85 0888f3d4-9f52-45d2-93bc-d00801ff5e46 --- src/DumpGH.c | 13 +++++++------ src/Startup.c | 44 +++++++++++++++++++++----------------------- src/Write.c | 5 ++--- src/ioStreamedHDF5GH.h | 9 ++++++--- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/DumpGH.c b/src/DumpGH.c index b75ed6b..0e65172 100644 --- a/src/DumpGH.c +++ b/src/DumpGH.c @@ -234,7 +234,8 @@ static int Checkpoint (const cGH *GH, int called_from) ioUtilGH->ioproc_every = CCTK_nProcs (GH); /* now open the file */ - if (CCTK_MyProc (GH) == ioUtilGH->ioproc && myGH->checkpoint_socket >= 0) + if (CCTK_MyProc (GH) == ioUtilGH->ioproc && + myGH->checkpoint_socket != INVALID_SOCKET) { if (CCTK_Equals (verbose, "full")) { @@ -246,8 +247,8 @@ static int Checkpoint (const cGH *GH, int called_from) if (file < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Can't create checkpoint file on port %d. " - "Checkpointing is skipped.", checkpoint_port); + "Can't create checkpoint file on port %u. " + "Checkpointing is skipped.", myGH->checkpoint_port); retval = -1; } } @@ -276,9 +277,9 @@ static int Checkpoint (const cGH *GH, int called_from) if (CCTK_Equals (verbose, "full")) { CCTK_VInfo (CCTK_THORNSTRING, "Waiting %d seconds to send " - "checkpoint file to port %d", + "checkpoint file to port %u", checkpoint_accept_timeout, - checkpoint_port); + myGH->checkpoint_port); } FD_ZERO (&readset); @@ -290,7 +291,7 @@ static int Checkpoint (const cGH *GH, int called_from) if (CCTK_Equals (verbose, "full")) { CCTK_VInfo (CCTK_THORNSTRING, "Closing checkpoint file on port %d", - checkpoint_port); + myGH->checkpoint_port); } HDF5_ERROR (H5Fclose (file)); } 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 -#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); } } diff --git a/src/Write.c b/src/Write.c index 303c6be..788f3b6 100644 --- a/src/Write.c +++ b/src/Write.c @@ -13,7 +13,6 @@ #include "cctk.h" #include "cctk_Parameters.h" -#include "StoreNamedData.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "CactusPUGHIO/IOHDF5Util/src/ioHDF5UtilGH.h" #include "ioStreamedHDF5GH.h" @@ -97,12 +96,12 @@ int IOStreamedHDF5_Write (const cGH *GH, int vindex, const char *alias) ioUtilGH->ioproc_every = CCTK_nProcs (GH); file = -1; - if (CCTK_MyProc (GH) == 0 && myGH->data_socket >= 0) + if (CCTK_MyProc (GH) == 0 && myGH->data_socket != INVALID_SOCKET) { if (CCTK_Equals (verbose, "full")) { CCTK_VInfo (CCTK_THORNSTRING, "Opening HDF5 output file " - "on data output port %d", data_port); + "on data output port %u", myGH->data_port); } /* set file access property list to use the Stream VFD diff --git a/src/ioStreamedHDF5GH.h b/src/ioStreamedHDF5GH.h index f8dc2c7..874610a 100644 --- a/src/ioStreamedHDF5GH.h +++ b/src/ioStreamedHDF5GH.h @@ -10,6 +10,7 @@ #ifndef _IOSTREAMEDHDF5_IOSTREAMEDHDF5GH_H_ #define _IOSTREAMEDHDF5_IOSTREAMEDHDF5GH_H_ +#include "SocketUtils.h" #include "CactusPUGHIO/IOHDF5Util/src/ioHDF5UtilGH.h" @@ -23,11 +24,13 @@ typedef struct ioRequest **requests; /* the last iteration output */ - int *out_last; + int *out_last; + + /* ports to output data and checkpoint files to */ + unsigned int data_port, checkpoint_port; /* sockets to output data and checkpoint files to */ - int data_socket; - int checkpoint_socket; + SOCKET data_socket, checkpoint_socket; /* file access property list used to write checkpoint files */ hid_t checkpoint_fapl; -- cgit v1.2.3