[Ace-users] [ace-users] ACE_Message_Block: appending two strings - incorrect after getq

Douglas C. Schmidt schmidt at dre.vanderbilt.edu
Thu Oct 25 20:38:17 CDT 2007


Hi Bob,

Thanks for using the PRF.

>ACE VERSION: 5.5

Please upgrade to ACE+TAO+CIAO x.6.1 (i.e., ACE 5.6.1, TAO 1.6.1, and
CIAO 0.6.1), which you can download from

http://download.dre.vanderbilt.edu

under the heading: "Latest Beta Kit."

The DOC groups at Washington University, UC Irvine, and Vanderbilt
University only provide "best effort" support for non-sponsors for the
latest release, as described in

http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/docs/ACE-bug-process.html

Thus, if you need more "predictable" help for earlier versions of
ACE+TAO, I recommend that you check out

http://www.dre.vanderbilt.edu/support.html

for a list of companies that will provide you with ACE+TAO commercial
support.

>    HOST MACHINE and OPERATING SYSTEM:
>        Windows XP
>
>
>    SYNOPSIS:
>	Appending two strings in ACE_Message_Block produces incorrect results
>after getq()
>
>    DESCRIPTION:
>
>	ACE_Message_Block *mb = new ACE_Message_Block();

Why are you dynamically allocating mb twice?!

>	ACE_NEW_RETURN (mb, ACE_Message_Block(1024), -1);

The following line of code is non-portable:

>	char * string1 = "string1";

his should be

    const char *string = "string1";

>	mb->copy(string1);
>	// move the pointer
>	message->wr_ptr (ACE_OS::strlen (message->rd_ptr ()));

Same problem here:

>	char * string2 = "string2";
>	mb->copy(string2);
>	// move the pointer
>	message->wr_ptr (ACE_OS::strlen (message->rd_ptr ()));
>	ACE_ASSERT(this->putq(message)!=-1);
>	ACE_DEBUG((LM_DEBUG,"Enqueued msg successfully\n"));
>	return 0;
>
>
>	// in process_message() under svc
>
>	const char * string1 = message->rd_ptr();
>	cout << " string1" << string1 << endl; // String OK
>	// move the pointer
>	message->rd_ptr (ACE_OS::strlen (message->rd_ptr ()));
>
>	const char * string2 = message->rd_ptr();
>	cout << " string2 " << string2 << endl; // String screwed up
>
>	message->release ();

This looks to me like a "fence-post" error.  Please spend some time in
the debugger figuring out what you're doing wrong.

Thanks,

        Doug


-- 
Dr. Douglas C. Schmidt                       Professor and Associate Chair
Electrical Engineering and Computer Science  TEL: (615) 343-8197
Vanderbilt University                        WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203                          NET: d.schmidt at vanderbilt.edu



More information about the Ace-users mailing list