[omniORB] Calculating the message size of a response

Duncan Grisby duncan at grisby.org
Tue Jan 5 17:05:39 GMT 2010


On Mon, 2010-01-04 at 21:19 +0000, Floris Bruynooghe wrote:

> When the giopMaxMsgSize is exceeded the server code never knows this
> and the client code just gets a COMM_FAILURE instead of a more
> meaningful error.

Yes. That's because in most cases, the server has started sending the
data before it knows it is going to be too big. Once it has started
sending the reply, it can't send a more meaningful exception.

> Is it somehow possible to calculate the size of a message before
> sending it on the server side?  Basically perform the marshalling
> (from within python) and check the result so you could decide to raise
> a custom exception which is more specific.  (Bonus points for then
> being able to send this already marshalled data instead of having to
> repeat that)

Well, you can use the omniORB.cdrMarshal function to marshal the data
into a string. There's no way to then send that as the reply, so you
would end up doing the marshalling work twice, and you'd have to hold
the whole marshalled data in memory rather than streaming it over the
network.

At a C++ level, there is a cdrCountingStream class that you can use to
work out how big data will be without storing the marshalled form. That
isn't currently exposed to Python code, but I suppose you could add
something similar to the cdrMarshal function that did it. The other
limitation is that you can't use it if you are using valuetypes, since
the valuetype chunked encoding size is dependent on the buffering of the
data.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --





More information about the omniORB-list mailing list