IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15411


Ignore:
Timestamp:
Oct 29, 2007, 11:36:02 AM (19 years ago)
Author:
Paul Price
Message:

Replacing mmap with psSlurp. The proper behaviour of mmap when the
file size is a multiple of the page size seems to be somewhat open to
interpretation (even though we think it should do what we want it to).

See https://bugs.gentoo.org/show_bug.cgi?id=197191

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r14983 r15411  
    1111*  @author Joshua Hoblitt, University of Hawaii 2006-2007
    1212*
    13 *  @version $Revision: 1.140 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2007-09-22 03:05:50 $
     13*  @version $Revision: 1.141 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2007-10-29 21:36:02 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2626#include <limits.h>
    2727#include <strings.h>
     28#ifdef USE_MMAP_TO_READ_FILE
    2829#include <sys/mman.h>
    2930#include <sys/stat.h>
    3031#include <fcntl.h>
    3132#include <unistd.h>
     33#else
     34#include "psSlurp.h"
     35#endif
    3236
    3337#include "psMemory.h"
     
    11771181    PS_ASSERT_STRING_NON_EMPTY(filename, NULL);
    11781182
     1183#ifdef USE_MMAP_TO_READ_FILE
    11791184    // Attempt to open specified file
    11801185    int fd = 0;
     
    12201225        return NULL;
    12211226    }
    1222 
    1223     bool success = true;
     1227#else
     1228    psString file = psSlurpFilename(filename);
     1229#endif
    12241230
    12251231    md = psMetadataConfigParse(md, nFail, (char *)file, overwrite);
    12261232    if (!md) {
    12271233        psError(PS_ERR_IO, true, _("failed to parse file '%s'"), filename);
    1228         success = false;
    1229     }
    1230 
     1234        psFree(md);
     1235        return false;
     1236    }
     1237
     1238#ifdef USE_MMAP_TO_READ_FILE
    12311239    if (munmap(file, nBytes) != 0) {
    12321240        psError(PS_ERR_IO, true, _("failed to munmap file '%s'"), filename);
    1233         success = false;
     1241        psFree(md);
     1242        return false;
    12341243    }
    12351244
    12361245    if (close(fd) != 0) {
    12371246        psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename);
    1238         success = false;
    1239     }
    1240 
    1241     if (!success) {
    1242         psFree (md);
    1243         return NULL;
    1244     }
     1247        psFree(md);
     1248        return false;
     1249    }
     1250#else
     1251    psFree(file);
     1252#endif
     1253
    12451254    return md;
    12461255}
Note: See TracChangeset for help on using the changeset viewer.