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

Bob yesbkay at yahoo.com
Thu Oct 25 20:26:51 CDT 2007


ACE VERSION: 5.5

    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();
	ACE_NEW_RETURN (mb, ACE_Message_Block(1024), -1);

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

	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 ();



More information about the Ace-users mailing list