aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2001-03-15 16:15:14 +0000
committertradke <tradke@0888f3d4-9f52-45d2-93bc-d00801ff5e46>2001-03-15 16:15:14 +0000
commitf605e095033cd0fe7bec60a760d68ff11bb736d9 (patch)
treeabf83ba375bd480c25cf23970dd9ae9148121921
parent9275c5097d530aeaea9058e82cdaa2d07a380f6c (diff)
Clean up the temporary advertised file at termination.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@65 0888f3d4-9f52-45d2-93bc-d00801ff5e46
-rw-r--r--src/Startup.c32
-rw-r--r--src/ioStreamedHDF5GH.h2
2 files changed, 22 insertions, 12 deletions
diff --git a/src/Startup.c b/src/Startup.c
index 198599e..0e612d1 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -181,7 +181,6 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
char hostname[256];
ioStreamedHDF5GH *myGH;
FILE *advertised_file_fd;
- char advertised_filename[L_tmpnam];
ioAdvertisedFileDesc advertised_file;
@@ -245,20 +244,29 @@ static void *IOStreamedHDF5_SetupGH (tFleshConfig *config,
/* write the hostname/portnumber information in a temporary file
which gets advertised and then can be downloaded */
myGH->advertised_filename = (char *) malloc (L_tmpnam);
- if (tmpnam (myGH->advertised_filename))
+ if (myGH->advertised_filename && tmpnam (myGH->advertised_filename))
{
advertised_file_fd = fopen (myGH->advertised_filename, "w");
- fprintf (advertised_file_fd, "Hostname: %s\n", hostname);
- fprintf (advertised_file_fd, "Data port: %d", data_port);
- fclose (advertised_file_fd);
- advertised_file.slice = "";
- advertised_file.thorn = CCTK_THORNSTRING;
- advertised_file.varname = "All variables";
- advertised_file.description = "Streamed HDF5 data";
- advertised_file.mimetype = "data/streamed-hdf5";
-
- IOUtil_AdvertiseFile (GH, myGH->advertised_filename, &advertised_file);
+ if (advertised_file_fd)
+ {
+ fprintf (advertised_file_fd, "Hostname: %s\n", hostname);
+ fprintf (advertised_file_fd, "Data port: %d", data_port);
+ fclose (advertised_file_fd);
+
+ advertised_file.slice = "";
+ advertised_file.thorn = CCTK_THORNSTRING;
+ advertised_file.varname = "All variables";
+ advertised_file.description = "Streamed HDF5 data";
+ advertised_file.mimetype = "data/streamed-hdf5";
+
+ IOUtil_AdvertiseFile (GH, myGH->advertised_filename,&advertised_file);
+ }
+ else
+ {
+ CCTK_WARN (2, "Couldn't create unique temporary file ! "
+ "HDF5 data streaming was not advertised.");
+ }
}
else
{
diff --git a/src/ioStreamedHDF5GH.h b/src/ioStreamedHDF5GH.h
index 2ec98f6..d770bb6 100644
--- a/src/ioStreamedHDF5GH.h
+++ b/src/ioStreamedHDF5GH.h
@@ -40,6 +40,8 @@ typedef struct
int print_timing_info;
int timers[IOHDF5_NUM_TIMERS];
+ /* filename for advertising the hostname / port number information */
+ char *advertised_filename;
} ioStreamedHDF5GH;
#ifdef __cplusplus