[Ace-users] [ace-users] [ACE svc_handler message queue] message not added to the queue

Mateusz Berezecki mateusz.berezecki at meme.pl
Wed Mar 12 06:04:26 CDT 2008


Hello list readers,

I have a following problem with ACE 5.6.3

		const size_t max_payload_size = 8192;
		ACE_OutputCDR payload(max_payload_size);
		
		/* message serialization
		 * note: this basically boils down to
		 * payload << msg; but we have to do it
		 * the 'right-way' via an interface */
		msg.serialize(payload);
				
		/* Creates message header containing byte order,
		 * payload length and message type */
		
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("%IMessage length is %d (%d)\n"),
				payload.total_length(), msg.length()));
		
		ACE_CDR::ULong length = payload.total_length();
		ACE_OutputCDR header(ACE_CDR::MAX_ALIGNMENT + MESSAGE_HEADER_SIZE);
		
		header << ACE_OutputCDR::from_boolean(ACE_CDR_BYTE_ORDER);
		header << ACE_CDR::ULong(length);
		header << msg.type();
		header << msg.priority();
		
		ACE_Message_Block *header_block, *data_block;
		
		ACE_NEW_RETURN(header_block, ACE_Message_Block(MESSAGE_HEADER_SIZE),  
-1);
		ACE_NEW_RETURN(data_block, ACE_Message_Block(length), -1);
		
		/* dump serialized data from header CDR structure
		 * to header_block which holds final binary data */
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("Writing %d bytes to the header  
message block\n"), header.total_length()));
		
		if (!header.write_char_array(header_block->wr_ptr(),  
MESSAGE_HEADER_SIZE))
		{
			ACE_DEBUG((LM_ERROR, ACE_TEXT("Can't write header. Why?\n")));
		}
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("Length of header block after write is  
%d bytes.\n"), header_block->length()));
		/* dump serialized data from data CDR structure
		 * to data_block which holds final binary data */
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("Writing %d bytes to the data message  
block\n"), length));
		
		payload.write_char_array(data_block->wr_ptr(), length);
		
		
		/* Chain header and data message blocks together */
		header_block->cont(data_block);
		
		/* queue the message for sending. */
		ACE_DEBUG((LM_DEBUG, ACE_TEXT("Queueing message of length %d in the  
send queue.\n"), header_block->total_length()));
		this->putq(header_block);


the code above does not really copy the data into the message blocks.
I have no idea why but the output is pasted below:

$ ./services/transporttest
(...)
Message length is 8 (8)
Writing 16 bytes to the header message block
Length of header block after write is 0 bytes.
Writing 8 bytes to the data message block
Queueing message of length 0 in the send queue.
(...)
Message of length 0 fetched from the send queue.
0 bytes transferred.
releasing message from the queue
(...)
$


Does anybody have any suggestions?

best regards,
Mateusz Berezecki



More information about the Ace-users mailing list