[Ace-users] [ace-users] WIN32_Asynch_IO.cpp : error in iovec construction fromchain of message blocks
Johnny Willemsen
jwillemsen at remedy.nl
Sun Nov 4 14:06:17 CST 2007
Hi,
In the writev method there are two ++iovcnt increments. Do we need to have
both, I think the last one needs to be removed. Can you have a look.
Regards,
Johnny Willemsen
Remedy IT
Postbus 101
2650 AC Berkel en Rodenrijs
The Netherlands
www.theaceorb.nl / www.remedy.nl
*** Integrated compile and test statistics see
http://scoreboard.theaceorb.nl <http://scoreboard.theaceorb.nl/> ***
*** Commercial service and support for ACE/TAO/CIAO ***
*** See http://www.theaceorb.nl/en/support.html ***
________________________________
From: ace-users-bounces at cse.wustl.edu
[mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Alexander Libman
Sent: Friday, November 02, 2007 5:56 AM
To: ace-bugs at cs.wustl.edu
Cc: ace-users at cs.wustl.edu
Subject: [ace-users] WIN32_Asynch_IO.cpp : error in iovec
construction fromchain of message blocks
ACE VERSION: 5.6.1
HOST MACHINE and OPERATING SYSTEM:
WINDOWS - any
TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
COMPILER NAME AND VERSION (AND PATCHLEVEL):
WINDOWS - any
THE $ACE_ROOT/ace/config.h FILE [if you use a link to a
platform-
specific file, simply state which one]:
THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if
you
use a link to a platform-specific file, simply state which one
(unless this isn't used in this case, e.g., with Microsoft
Visual
C++)]:
CONTENTS OF
$ACE_ROOT/bin/MakeProjectCreator/config/default.features
(used by MPC when you generate your own makefiles):
AREA/CLASS/EXAMPLE AFFECTED:
DOES THE PROBLEM AFFECT:
COMPILATION?
no
LINKING?
no
EXECUTION?
yes
OTHER (please specify)?
no
SYNOPSIS:
Error in construction iovec from the chain of message blocks.
DESCRIPTION:
If any message block in chain has empty space (readv) or zero length
(writev),
iovec constructed with extra uninitialized element. We have this
error for 6 years,
I need glasses:)
REPEAT BY:
SAMPLE FIX/WORKAROUND:
Here is fix for readv, same for writev
WIN32_Asynch_IO.cpp
00439 #if (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
00440 iovec iov[ACE_IOV_MAX
<http://www.dre.vanderbilt.edu/Doxygen/Current/html/ace/a01287.html#f2a34d22
026b6e2899992232d24da22b> ];
00441 int iovcnt = 0;
00442
00443 // We should not read more than user requested,
00444 // but it is allowed to read less
00445
00446 for (const ACE_Message_Block
<http://www.dre.vanderbilt.edu/Doxygen/Current/html/ace/a00324.html> * msg =
&message_block;
00447 msg != 0 && bytes_to_read > 0 && iovcnt < ACE_IOV_MAX
<http://www.dre.vanderbilt.edu/Doxygen/Current/html/ace/a01287.html#f2a34d22
026b6e2899992232d24da22b> ;
****** Replace here
00448--- msg = msg->cont () , ++iovcnt )
00448+++ msg = msg->cont ())
00449 {
00450 size_t msg_space = msg->space ();
00451
***** This comment can be removed
00452 // OS should correctly process zero length buffers
00453 // if ( msg_space == 0 )
00454 // ACE_ERROR_RETURN ((LM_ERROR,
00455 // ACE_TEXT
("ACE_WIN32_Asynch_Read_Stream::readv:")
00456 // ACE_TEXT ("No space in the message
block\n")),
00457 // -1);
00458
***** End of comment to be removed
00459 if (msg_space > bytes_to_read)
00460 msg_space = bytes_to_read;
00461 bytes_to_read -= msg_space;
00462
00463 // Make as many iovec as needed to fit all of msg_space.
00464 size_t wr_ptr_offset = 0;
00465 while (msg_space > 0 && iovcnt < ACE_IOV_MAX)
00466 {
00467 u_long this_chunk_length;
00468 if (msg_space > ULONG_MAX)
00469 this_chunk_length = ULONG_MAX;
00470 else
00471 this_chunk_length = static_cast<u_long> (msg_space);
00472 // Collect the data in the iovec.
00473 iov[iovcnt].iov_base = msg->wr_ptr () + wr_ptr_offset;
00474 iov[iovcnt].iov_len = this_chunk_length;
00475 msg_space -= this_chunk_length;
00476 wr_ptr_offset += this_chunk_length;
00477
00478 // Increment iovec counter if there's more to do.
******** The following if should be removed
00479--- if (msg_space > 0)
******* This should be preserved
00480 ++iovcnt;
00481 }
00482 if (msg_space > 0) // Ran out of iovecs before
msg_space exhausted
00483 {
00484 errno = ERANGE;
00485 return -1;
00486 }
00487 }
00488
00489 // Re-calculate number bytes to read
00490 bytes_to_read = 0;
00491
00492 for (int i = 0; i < iovcnt ; ++i)
00493 bytes_to_read += iov[i].iov_len;
00494
....
More information about the Ace-users
mailing list