Project

General

Profile

Bug #1043 » diff_thoralf.diff

thoralf schulze, 30 Mar 2015 18:16

View differences:

src/basicio.cpp 2015-03-30 20:13:48.483504567 +0200
368 368

  
369 369
    int FileIo::munmap()
370 370
    {
371
        std::cout << "fileio::munmap\n";
372
/* #if defined EXV_HAVE_MMAP
373
        std::cout << " … compiled w/ EXV_HAVE_MMAP\n";
374
#else
375
        std::cout << " … compiled w/o EXV_HAVE_MMAP\n";
376
#endif
377
#if defined EXV_HAVE_MUNMAP
378
        std::cout << " … compiled w/ EXV_HAVE_MUNMAP\n";
379
#else
380
        std::cout << " … compiled w/o EXV_HAVE_MUNMAP\n";
381
#endif
382
*/
371 383
        int rc = 0;
384
        // compiler won't allow this
385
        // byte foo = 0;
386
        // foo = p_->pMappedArea_;
387
        // std::cout << " … mappedarea: " << foo << "\n";
388
        //
389
        // if this is commented in, the rest of the method is not being
390
        //   executed (it seems to exit immediately), and the hang occurs
391
        // std::cout << " … mappedarea: " << p_->pMappedArea_ << "\n";
372 392
        if (p_->pMappedArea_ != 0) {
373 393
#if defined EXV_HAVE_MMAP && defined EXV_HAVE_MUNMAP
394
            // this block is never, ever being called. the relevant compiler
395
            // macros are definitely defined, see the tests above and below
396
            std::cout << " … about to enter munmap\n";
397
            std::cout << " … mappedArea: " << p_->pMappedArea_ << "\n";
374 398
            if (::munmap(p_->pMappedArea_, p_->mappedLength_) != 0) {
399
                std::cout << "   … inside munmap\n";
400
                std::cout << "   … mappedLength: " << p_->mappedLength_ << "\n";
375 401
                rc = 1;
376 402
            }
377 403
#elif defined WIN32 && !defined __CYGWIN__
404
            std::cout << "win32 w/o cygwin\n"
378 405
            UnmapViewOfFile(p_->pMappedArea_);
379 406
            CloseHandle(p_->hMap_);
380 407
            p_->hMap_ = 0;
381 408
            CloseHandle(p_->hFile_);
382 409
            p_->hFile_ = 0;
383 410
#else
411
            std::cout << "!EXV_HAVE_MMAP && !EXV_HAVE_MUNMAP\n";
384 412
            if (p_->isWriteable_) {
413
                std::cout " … iswriteable\n"
385 414
                seek(0, BasicIo::beg);
386 415
                write(p_->pMappedArea_, p_->mappedLength_);
387 416
            }
388 417
            if (p_->isMalloced_) {
418
                std::cout " … ismalloced\n"
389 419
                delete[] p_->pMappedArea_;
390 420
                p_->isMalloced_ = false;
391 421
            }
392 422
#endif
393 423
        }
424
        std::cout << " … common block\n";
425
        std::cout << "   … iswriteable: " << p_->isWriteable_ << "\n";
394 426
        if (p_->isWriteable_) {
395
            if (p_->fp_ != 0) p_->switchMode(Impl::opRead);
427
            std::cout << "   … is writeable.\n";
428
            if (p_->fp_ != 0) {
429
                p_->switchMode(Impl::opRead);
430
                std::cout << "   … fp != 0\n";
431
            }
396 432
            p_->isWriteable_ = false;
397 433
        }
398 434
        p_->pMappedArea_ = 0;
399 435
        p_->mappedLength_ = 0;
436
        std::cout << " … return value: " << rc << "\n";
400 437
        return rc;
401 438
    }
402 439

  
403 440
    byte* FileIo::mmap(bool isWriteable)
404 441
    {
442
        std::cout << "fileio::mmap\n";
405 443
        assert(p_->fp_ != 0);
406 444
        if (munmap() != 0) {
407 445
#ifdef EXV_UNICODE_PATH
(3-3/3)