octet sequence problem with ORBit2 client
- From: Bart Vanherck <bvanherck maia-scientific com>
- To: orbit-list <orbit-list gnome org>
- Subject: octet sequence problem with ORBit2 client
- Date: Fri, 24 Sep 2004 09:40:16 +0200
Hello,
I have a question about sequences.
I have the following idl :
typedef sequence<octet> HelloBuf;
module Hello{
struct T_HELLOWORLD{
string name;
short type;
HelloBuf data;
};
interface World {
T_HELLOWORLD GetData(in string name);
};
};
Now I want to allocate a data buffer in the server and send this buffer
back to our client. The data buffer contains some binary data.
When I ask to our server such a buffer, the client gets an error.
"IDL:omg.org/CORBA/COMM_FAILURE:1.0" (in ev )
Now the strange thing is that this happens when server and client are
not on the same machine AND if the client is linked with orbit2. If the
client is linked with orbit1 there is no problem.
This only happens if the structure that contains the buffer has a length
that is greater than 2^18 ! So a length of 300 or 30000 works, but not a
buffer of 3000000 bytes.
Is this a bug in orbit2 or did I make a mistake ?
I include here an example HelloWorld in which the problem can be
reproduced. I did include just the code that is not generated with
orbit-idl (or orbit-idl-2)
#include <glib.h>
#include <stdio.h>
#include "glib.h"
#include "test.h" /* comes from test.idl */
/////////////////////////////////////////////////////////////////////////////////
// skelimpl
/////////////////////////////////////////////////////////////////////////////////
#include "skelimpl.c"
/* I include here the function which I implement */
static Hello_T_HELLOWORLD *
impl_Hello_World_GetData(impl_POA_Hello_World * servant,
CORBA_char * name, CORBA_Environment * ev)
{
Hello_T_HELLOWORLD *retval=NULL;
CORBA_octet *kar=NULL;
CORBA_unsigned_long length=0;
unsigned char j=0;
long i=0;
retval = Hello_T_HELLOWORLD__alloc();
retval->name = CORBA_string_dup(name);
length = atoi(name);
retval->type = 3;
retval->data._maximum = length;
retval->data._length = length;
retval->data._buffer =
CORBA_sequence_CORBA_octet_allocbuf(retval->data._maximum);
kar = retval->data._buffer;
for (i=0;i<retval->type;i++){
*kar = ( CORBA_octet )j;
kar++;
j++;
}
CORBA_sequence_set_release( &retval->data, TRUE );
return retval;
}
int main(int argc,char **argv){
CORBA_ORB orb;
CORBA_Environment *ev;
Hello_World obj;
CORBA_char* objref;
PortableServer_POA root_poa;
PortableServer_POAManager manager;
gchar *filename;
FILE *ofp;
filename =
g_strdup_printf("%s/helloworld.ior",getenv("IORFILE"));
if (filename) {
ofp = fopen(filename,"w");
if (ofp){
ev = g_new0(CORBA_Environment,1);
CORBA_exception_init(ev);
orb =
CORBA_ORB_init(&argc,argv,"orbit-local-orb",ev);
root_poa =
(PortableServer_POA)CORBA_ORB_resolve_initial_references(
orb,"RootPOA",ev);
manager =
PortableServer_POA__get_the_POAManager(root_poa,ev);
PortableServer_POAManager_activate(manager,ev);
obj = impl_Hello_World__create(root_poa,ev);
objref = CORBA_ORB_object_to_string(orb,obj,ev);
fprintf(ofp,"%s",objref);
fclose(ofp);
}
g_free(filename);
CORBA_ORB_run(orb,ev);
CORBA_Object_release(obj,ev);
CORBA_ORB_shutdown(orb,CORBA_FALSE,ev);
}
return 0;
}
///////////////////////////////////////////
// CLIENT CODE
///////////////////////////////////////////
#include <stdio.h>
#include <glib.h>
#include "test.h"
int main(int argc,char **argv){
char filebuf[1024];
CORBA_Environment ev;
CORBA_ORB orb;
Hello_World world;
gchar *filename;
gchar *genior=NULL;
gchar *name=NULL;
Hello_T_HELLOWORLD *retval=NULL;
FILE *ifp;
filename =
g_strdup_printf("%s/helloworld.ior",getenv("IORFILE"));
if (filename){
CORBA_exception_init (&ev);
orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb",
&ev);
ifp = fopen (filename, "r");
if (ifp){
fgets (filebuf, 1023, ifp);
genior = g_strdup (filebuf);
fclose(ifp);
}
if (genior){
world = CORBA_ORB_string_to_object (orb, genior,
&ev);
g_free(genior);
}
g_free(filename);
}
if (world){
name = g_strdup_printf("%s","3000000");
if (name){
retval = Hello_World_GetData(world,name,&ev);
if (ev._major == CORBA_NO_EXCEPTION ){
g_print("RETVAL is valid\n");
} else {
g_print("RETVAL is NOT valid\n");
}
g_free(name);
}
}
return 0;
}
regards,
Bart
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]