diff options
author | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-11-21 02:46:39 +0000 |
---|---|---|
committer | kitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-11-21 02:46:39 +0000 |
commit | 59680642d3569380f0cf0a61603c0035b4468e7b (patch) | |
tree | be36d115c40abfe4c94bea34cda72430795b7e91 | |
parent | 1082772e2d79bf1d86127a55ac0ea8f8a8193f3e (diff) | |
download | ATCD-59680642d3569380f0cf0a61603c0035b4468e7b.tar.gz |
ChangeLogTag: Wed Nov 20 20:44:56 2002 Krishnakumar B <kitty@cs.wustl.edu>
-rw-r--r-- | ACEXML/ChangeLog | 11 | ||||
-rw-r--r-- | ACEXML/common/HttpCharStream.cpp | 2 | ||||
-rw-r--r-- | ACEXML/common/Mem_Map_Stream.cpp | 63 |
3 files changed, 57 insertions, 19 deletions
diff --git a/ACEXML/ChangeLog b/ACEXML/ChangeLog index debbb0c2767..3b1aba30e7b 100644 --- a/ACEXML/ChangeLog +++ b/ACEXML/ChangeLog @@ -1,3 +1,14 @@ +Wed Nov 20 20:44:56 2002 Krishnakumar B <kitty@cs.wustl.edu> + + * common/Mem_Map_Stream.cpp (grow_file_and_remap): + + Fixed bug where we were trying to remap two different files at + the same location without closing the first. + + * common/HttpCharStream.cpp (get_url): + + Don't try to parse an empty file. Removes a nasty SIGSEGV. + Wed Nov 20 01:06:26 2002 Krishnakumar B <kitty@cs.wustl.edu> * common/Mem_Map_Stream.cpp: diff --git a/ACEXML/common/HttpCharStream.cpp b/ACEXML/common/HttpCharStream.cpp index 80c41cf511d..4cd22a71617 100644 --- a/ACEXML/common/HttpCharStream.cpp +++ b/ACEXML/common/HttpCharStream.cpp @@ -214,6 +214,8 @@ ACEXML_HttpCharStream::get_url (size_t& len) } } end_of_headers: + if (b == 0) + return -1; ++b; // Store the address of the beginning of data. We will use it to seek to // beginning of the data in the URL. diff --git a/ACEXML/common/Mem_Map_Stream.cpp b/ACEXML/common/Mem_Map_Stream.cpp index 2c6e4b9a874..907cd6467fb 100644 --- a/ACEXML/common/Mem_Map_Stream.cpp +++ b/ACEXML/common/Mem_Map_Stream.cpp @@ -67,8 +67,10 @@ const char * ACEXML_Mem_Map_Stream::recv (size_t &len) { if (this->eof () && this->grow_file_and_remap () == -1) - return 0; - + { + len = 0; + return 0; + } const char *s = this->recv_pos_; this->seek (len, SEEK_CUR); len = this->get_pos_ - s; @@ -187,31 +189,55 @@ ACEXML_Mem_Map_Stream::open (Connector *connector, int ACEXML_Mem_Map_Stream::grow_file_and_remap (void) { - char buf[BUFSIZ + 1]; + char buf[65536]; // Copy the next chunk of bytes from the socket into the temporary // file. ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT); - - ssize_t n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv); - if (n == -1) + ssize_t bytes = 0; + ssize_t n = 0; + while (1) { - ACE_ERROR ((LM_ERROR, "%p\n", "recv")); - return -1; + n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv); + if (n == -1) + { + if (errno != EWOULDBLOCK) + { + ACE_ERROR ((LM_ERROR, "%p\n", "recv")); + return -1; + } + } + bytes += n; + if (n == 0 && !bytes) + return -1; + else if (n == 0) + break; + else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "write_n"), + -1); } - else if (n == 0) - return -1; - else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "write_n"), - -1); + +// ssize_t n = this->svc_handler_->peer ().recv (buf, sizeof buf, 0, &tv); +// if (n == -1) +// { +// ACE_ERROR ((LM_ERROR, "%p\n", "recv")); +// return -1; +// } +// else if (n == 0) +// return -1; +// else if (ACE::write_n (this->mem_map_.handle (), buf, n) != n) +// ACE_ERROR_RETURN ((LM_ERROR, +// "%p\n", +// "write_n"), +// -1); // Grow the memory-mapping to encompass the entire temporary file. if (this->mem_map_.map (-1, PROT_RDWR, - ACE_MAP_PRIVATE | ACE_MAP_FIXED, - ACE_DEFAULT_BASE_ADDR) == -1) + ACE_MAP_PRIVATE, + (void*)0) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "map"), @@ -219,8 +245,7 @@ ACEXML_Mem_Map_Stream::grow_file_and_remap (void) // MAP_FAILED is used as a "first time in" flag. if (this->recv_pos_ == MAP_FAILED) { - this->recv_pos_ = ACE_reinterpret_cast (char *, - this->mem_map_.addr ()); + this->recv_pos_ = ACE_reinterpret_cast (char *, this->mem_map_.addr ()); this->get_pos_ = this->recv_pos_; } |