Re: ORBit transfer of image data - more info please

Michael Meeks <[email protected]>
Newsgroups gmane.comp.gnome.components,gmane.comp.gnome.orbit.general
Organization Ximian.
Message-ID <[email protected]>
Hi Peter,

On Fri, 2003-04-25 at 13:23, Peter Van Osta wrote:
> I don't seem to get it right to transfer images from the server to the
> client, on the client side I ahve the following code:

	:-) cf. my comments on your bugreport.

> 	ret = Ezx_Srvr_ReadImage( server, &img, &strg, &message, &ev );

	For an inout sequence things are complicated; I think you're likely to
be on-course for much confusion if you go this way; why don't you simply
return the structure, and then free it ? I forget the exact semantics
myself. AFAIR though with an inout sequence argument you have to
allocate the _buffer; for it to free (or send a 0 length sequence in),
the ORB will free that, and replace it with the new value on return -
but as I say - it's a potentially confusing way to use the binding, and
scripting languages tend not to like out/inout arguments anyway so ...

> 	if( message )
> 		CORBA_free( message );

	It's worth noting that you have to check for an exception before using
the return value of a CORBA method; on exception the return values are
undefined (freed/uninitialized by the ORB itself); so you need:

	if (ev._major != CORBA_NO_EXCEPTION) {
		handle_error;
		return;
	}

> On the server side I just put the following code for a test, but all I
> get is a "core" dump:

	OK;

> static CORBA_short impl_Ezx_Srvr_ReadImage(impl_POA_Ezx_Srvr * servant,
> 			Ezx_EzxImgObj * Ezximg,
> 			Ezx_EzxRdrDatastoreObj * Ezxstrg,
> 			CORBA_char ** message, CORBA_Environment * ev)
> {
> 	CORBA_short retval = ( CORBA_short )IE_OK;
	
	The problem is; that the ORB for efficiency reasons, will not
initialize your 'out' arguments to contain valid data - that would then
have to detect whether it was overwritten / free it before returning the
values - that would be ghastly ;-) Instead the ORB assumes that for out
arguments and return values - you will return valid data that it can
marshal back (or an exception).

	Thus - this method will blow the ORB's mind when it tries to marshal
the contents of *message (eg.) that is uninitialized - it needs to be a
CORBA_string_dup'ed string; [similarly for any other out args].

	HTH,

		Michael.

-- 
 [email protected]  <><, Pseudo Engineer, itinerant idiot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.