Commit f5b90eec8f7b481962ed835a7b4f08f418fe26db

Authored by Jürgen Knödlseder
1 parent 3411dd6b

Make GFilename::is_fits thread safe (#1717).

ChangeLog
1 -2016-02-25 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu> 1 +2016-02-28 Juergen Knoedlseder <jurgen.knodlseder@irap.omp.eu>
2 2
3 * Version 1.1.0 released 3 * Version 1.1.0 released
4 ========================= 4 =========================
5 5
  6 + Make GFilename::is_fits thread safe (#1717).
6 Revise GTime operators (#1714) 7 Revise GTime operators (#1714)
7 Add GSkyMap::publish() method to publish map on VO Hub (#1710) 8 Add GSkyMap::publish() method to publish map on VO Hub (#1710)
8 Add GVOClient::publish() method to publish a FITS HDU (#1710) 9 Add GVOClient::publish() method to publish a FITS HDU (#1710)
@@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 1.1.0 @@ -2,7 +2,7 @@ New Features and Important Changes in GammaLib 1.1.0
2 2
3 Author(s) : Juergen Knoedlseder 3 Author(s) : Juergen Knoedlseder
4 4
5 -25 February 2016 5 +28 February 2016
6 6
7 7
8 1. Introduction 8 1. Introduction
@@ -196,6 +196,9 @@ the access protocol (e.g. http, ftp, file) of the file name, the method @@ -196,6 +196,9 @@ the access protocol (e.g. http, ftp, file) of the file name, the method
196 path() returns the path of th file name, and the method file() returns the 196 path() returns the path of th file name, and the method file() returns the
197 file name without the path. 197 file name without the path.
198 198
  199 +Put FITS access in a critical OMP zone to make GFilename::is_fits() thread
  200 +safe (#1717).
  201 +
199 202
200 14. XML module 203 14. XML module
201 -------------- 204 --------------
src/support/GFilename.cpp
@@ -253,7 +253,7 @@ bool GFilename::exists(void) const @@ -253,7 +253,7 @@ bool GFilename::exists(void) const
253 * @return True if file is a FITS file. 253 * @return True if file is a FITS file.
254 * 254 *
255 * Test if the file or a compressed version of the file (with a .gz, .Z, .z, 255 * Test if the file or a compressed version of the file (with a .gz, .Z, .z,
256 - * or .zip extension) is a FITS file. 256 + * or .zip extension) is a FITS file. This method is thread safe.
257 ***************************************************************************/ 257 ***************************************************************************/
258 bool GFilename::is_fits(void) const 258 bool GFilename::is_fits(void) const
259 { 259 {
@@ -261,14 +261,19 @@ bool GFilename::is_fits(void) const @@ -261,14 +261,19 @@ bool GFilename::is_fits(void) const
261 bool is_fits = false; 261 bool is_fits = false;
262 262
263 // Check now for a FITS file. This works only if cfitsio is available. 263 // Check now for a FITS file. This works only if cfitsio is available.
  264 + // Put the code into a critical zone as it might be called from within
  265 + // a parallelized thread.
264 #if defined(HAVE_LIBCFITSIO) 266 #if defined(HAVE_LIBCFITSIO)
265 - int status = 0;  
266 - fitsfile* fptr = NULL;  
267 - status = ffopen(&fptr, url().c_str(), 0, &status);  
268 - if (status == 0) {  
269 - is_fits = true; 267 + #pragma omp critical
  268 + {
  269 + int status = 0;
  270 + fitsfile* fptr = NULL;
  271 + status = ffopen(&fptr, url().c_str(), 0, &status);
  272 + if (status == 0) {
  273 + is_fits = true;
  274 + }
  275 + ffclos(fptr, &status);
270 } 276 }
271 - ffclos(fptr, &status);  
272 #endif 277 #endif
273 278
274 // Return result 279 // Return result