diff options
author | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-23 06:02:24 +0000 |
---|---|---|
committer | jxh <jxh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-05-23 06:02:24 +0000 |
commit | 62ee9cd303d6835b4b1746faf36ce6481c9ed542 (patch) | |
tree | 33ffe9b9a1b971903153a0901a92c2da6af98e61 | |
parent | 4045ae5c21871dc92001a8828e942b0755cc63df (diff) | |
download | ATCD-62ee9cd303d6835b4b1746faf36ce6481c9ed542.tar.gz |
Debugged acquire () method: writing didn't work at all aparently, map
was being called incorrectly.
-rw-r--r-- | apps/JAWS/server/JAWS_File.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/apps/JAWS/server/JAWS_File.cpp b/apps/JAWS/server/JAWS_File.cpp index a8241bbaf02..8a32a6c4a82 100644 --- a/apps/JAWS/server/JAWS_File.cpp +++ b/apps/JAWS/server/JAWS_File.cpp @@ -25,10 +25,11 @@ static const int READ_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | static const int WRITE_FLAGS = (FILE_FLAG_SEQUENTIAL_SCAN | FILE_FLAG_OVERLAPPED | O_RDWR | - O_CREAT); + O_CREAT | + O_TRUNC); #else static const int READ_FLAGS = O_RDONLY; -static const int WRITE_FLAGS = O_RDWR | O_CREAT; +static const int WRITE_FLAGS = O_RDWR | O_CREAT | O_TRUNC; #endif /* ACE_WIN32 */ // static data members @@ -387,13 +388,14 @@ JAWS_File::acquire (void) this->handle_ = ACE_OS::open (this->tempname_, READ_FLAGS, R_MASK); if (this->handle_ == ACE_INVALID_HANDLE) { - this->error (JAWS_File::OPEN_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: open"); } else if (this->mmap_.map (this->handle_, -1, - PROT_READ, MAP_PRIVATE) != 0 - || this->mmap_.map (this->tempname_) != 0) + PROT_READ, MAP_PRIVATE) != 0) { - this->error (JAWS_File::MEMMAP_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::MEMMAP_FAILED, + "JAWS_File::acquire: map"); ACE_OS::close (this->handle_); this->handle_ = ACE_INVALID_HANDLE; } @@ -404,12 +406,28 @@ JAWS_File::acquire (void) this->handle_ = ACE_OS::open (this->tempname_, WRITE_FLAGS, W_MASK); if (this->handle_ == ACE_INVALID_HANDLE) { - this->error (JAWS_File::OPEN_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: open"); + } + else if (ACE_OS::lseek (this->handle_, this->size_ - 1, SEEK_SET) + == -1) + { + this->error (JAWS_File::OPEN_FAILED, + "JAWS_File::acquire: lseek"); + ACE_DEBUG ((LM_DEBUG, "hey--> %d, %u, %d\n", this->handle_, this->size_, SEEK_SET)); + ACE_OS::close (this->handle_); + } + else if (ACE_OS::write (this->handle_, "", 1) != 1) + { + this->error (JAWS_File::WRITE_FAILED, + "JAWS_File::acquire: write"); + ACE_OS::close (this->handle_); } else if (this->mmap_.map (this->handle_, this->size_, PROT_RDWR, MAP_SHARED) != 0) { - this->error (JAWS_File::MEMMAP_FAILED, "JAWS_File::acquire"); + this->error (JAWS_File::MEMMAP_FAILED, + "JAWS_File::acquire: map"); ACE_OS::close (this->handle_); } break; @@ -500,7 +518,7 @@ JAWS_File::error (void) const int JAWS_File::error (int error_value, const char * s) { - ACE_ERROR ((LM_ERROR, "%p memory mapping for read.\n", s)); + ACE_ERROR ((LM_ERROR, "%p.\n", s)); return (this->error_ = error_value); } |