~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to cpp/src/IceUtil/FileUtil.cpp

  • Committer: Package Import Robot
  • Author(s): Michael Ziegler
  • Date: 2012-07-07 15:24:30 UTC
  • mfrom: (6.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120707152430-kktx4mfmywkz382j
Tags: 3.4.2-8.1
* Non-maintainer upload.
* Revert the patch 'fixing' the FTBFS with gcc-4.7 that breaks ABI, and
  add force_gcc_4.6.patch.  We need to do this all in the upstream makefile
  because it has a silly check for the intel icpc compiler that we need to
  patch around or the build will fail with anything but c++ as the compiler,
  and we can't just override CXX in /rules because the wonderful 3.0 (quilt)
  system will revert that patch before the clean target is run ensuring that
  hilarious fail is guaranteed.
  Closes: #672066

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#ifdef _WIN32
18
18
#  include <process.h>
19
 
#else
20
 
#  include <unistd.h>
21
19
#endif
22
20
 
23
21
#ifdef _WIN32
200
198
        throw IceUtil::FileLockException(__FILE__, __LINE__, GetLastError(), _path);
201
199
    }
202
200
    //
203
 
    // In Windows implementation we don't write the process pid to the file, as is
 
201
    // In Windows implementation we don't write the process pid to the file, as is 
204
202
    // not posible to read the file from other process while it is locked here.
205
203
    //
206
204
}
239
237
    {
240
238
        flags |= _O_WRONLY | _O_CREAT;
241
239
    }
242
 
    else
 
240
    else 
243
241
    {
244
242
        flags |= _O_RDWR;
245
243
        if(mode & ios_base::trunc)
468
466
    lock.l_whence = SEEK_SET; // Begining of file
469
467
    lock.l_start = 0;
470
468
    lock.l_len = 0;
471
 
 
 
469
    
472
470
    //
473
 
    // F_SETLK tells fcntl to not block if it cannot
474
 
    // acquire the lock, if the lock cannot be acquired
 
471
    // F_SETLK tells fcntl to not block if it cannot 
 
472
    // acquire the lock, if the lock cannot be acquired 
475
473
    // it returns -1 without wait.
476
474
    //
477
475
    if(::fcntl(_fd, F_SETLK, &lock) == -1)
485
483
    // If there is an error after here, we close the fd,
486
484
    // to release the lock.
487
485
    //
488
 
 
 
486
    
489
487
    //
490
488
    // Now that we have acquire an excluxive write lock,
491
489
    // write the process pid there.
492
490
    //
493
491
    ostringstream os;
494
492
    os << getpid();
495
 
 
 
493
    
496
494
    if(write(_fd, os.str().c_str(), os.str().size()) == -1)
497
495
    {
498
496
        IceUtil::FileLockException ex(__FILE__, __LINE__, errno, _path);