From f605e095033cd0fe7bec60a760d68ff11bb736d9 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 15 Mar 2001 16:15:14 +0000 Subject: 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 --- src/Startup.c | 32 ++++++++++++++++++++------------ src/ioStreamedHDF5GH.h | 2 ++ 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 -- cgit v1.2.3