Switch to unified view

a/src/utils/rclutil.cpp b/src/utils/rclutil.cpp
...
...
33
#endif
33
#endif
34
#include <math.h>
34
#include <math.h>
35
#include <errno.h>
35
#include <errno.h>
36
#include <sys/types.h>
36
#include <sys/types.h>
37
#include "safesysstat.h"
37
#include "safesysstat.h"
38
38
#include "ptmutex.h"
39
#include <mutex>
39
40
40
#include "rclutil.h"
41
#include "rclutil.h"
41
#include "pathut.h"
42
#include "pathut.h"
42
#include "wipedir.h"
43
#include "wipedir.h"
43
#include "transcode.h"
44
#include "transcode.h"
...
...
236
237
237
    // There is a race condition between name computation and
238
    // There is a race condition between name computation and
238
    // mkdir. try to make sure that we at least don't shoot ourselves
239
    // mkdir. try to make sure that we at least don't shoot ourselves
239
    // in the foot
240
    // in the foot
240
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
241
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
241
    static PTMutexInit mlock;
242
    static std::mutex mmutex;
242
    PTMutexLocker lock(mlock);
243
    std::unique_lock lock(mmutex);
243
#endif
244
#endif
244
245
245
    if (!
246
    if (!
246
#ifdef HAVE_MKDTEMP
247
#ifdef HAVE_MKDTEMP
247
            mkdtemp(cp)
248
            mkdtemp(cp)
...
...
259
    free(cp);
260
    free(cp);
260
#else // _WIN32
261
#else // _WIN32
261
    // There is a race condition between name computation and
262
    // There is a race condition between name computation and
262
    // mkdir. try to make sure that we at least don't shoot ourselves
263
    // mkdir. try to make sure that we at least don't shoot ourselves
263
    // in the foot
264
    // in the foot
264
    static PTMutexInit mlock;
265
    static std::mutex mmutex;
265
    PTMutexLocker lock(mlock);
266
    std::unique_lock lock(mmutex);
266
    tdir = path_wingettempfilename(TEXT("rcltmp"));
267
    tdir = path_wingettempfilename(TEXT("rcltmp"));
267
#endif
268
#endif
268
269
269
    // At this point the directory does not exist yet except if we used
270
    // At this point the directory does not exist yet except if we used
270
    // mkdtemp
271
    // mkdtemp
...
...
285
{
286
{
286
    // Because we need a specific suffix, can't use mkstemp
287
    // Because we need a specific suffix, can't use mkstemp
287
    // well. There is a race condition between name computation and
288
    // well. There is a race condition between name computation and
288
    // file creation. try to make sure that we at least don't shoot
289
    // file creation. try to make sure that we at least don't shoot
289
    // our own selves in the foot. maybe we'll use mkstemps one day.
290
    // our own selves in the foot. maybe we'll use mkstemps one day.
290
    static PTMutexInit mlock;
291
    static std::mutex mmutex;
291
    PTMutexLocker lock(mlock);
292
    std::unique_lock<std::mutex> lock(mmutex);
292
293
293
#ifndef _WIN32
294
#ifndef _WIN32
294
    string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
295
    string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
295
    char *cp = strdup(filename.c_str());
296
    char *cp = strdup(filename.c_str());
296
    if (!cp) {
297
    if (!cp) {