oneway methds & struct members

Sai-Lai Lo S.Lo@orl.co.uk
29 Aug 1997 18:19:51 +0100


Andrey Slepuhin <pooh@msu.ru> writes:

> 1) I want to send messages from client to server using server's method
> 
>   void AcceptMessage (Message msg);
> 
> All works fine and when server occasionally is down I catch
> CORBA::SystemException. But when method is declared as "oneway" I get
> "Broken pipe" on console instead of catching an exception. Is there a
> way to catch exceptions with "oneway" methods?

Hm.. Looks like your system is not catching the SIGPIPE signal. What
platform are you using? On the unix platforms we support, the signal mask
is set to ignore SIGPIPE.

> 2) Let S is a struct with members M1 of type T1 and M2 of type T2. I
> have
> 
>   S a;
>   ...
>   a.M2 = a.M1;
> 
> If T2 is equal to T1 I get correct assignement because necessary
> duplication is done by operator= which is called directly. But if T2
> inherits T1, assignement consists of to steps: by converting right side
> to a pointer and by assigning this pointer to left side, and in this case
> no duplication is done. Is this a bug or I must differ such two cases?

This is an interesting one. 

According to the C++ mapping (sec 16.9) "The behavior of the type is the
same as the normal mapping (char* for string, A_ptr for an interface A)."
Therefore in the assignment you are doing, the **correct** thing to do is to
duplicate:

    S a;
    ...
    a.M2 = T2::_duplicate(a.M1);

This works irrespective of whether T1 is equal in type to T2.

Nevertheless, your example actually points to a mucky area in the
mapping which causes the behaviour you observed. The mapping requests that
a struct's assignment operator and copy constructor have to deep copy all
its members. Each struct member must be self-managed. To support object ref
and string (which maps to C++ pointers) as struct member, a 'hidden' type
has to be used in its place. To support deep copy of the parent struct, the
hidden type for object reference has to do duplicate as well. But to
preserve the behaviour of the normal mapping, assignment operator for
A_ptr does not do duplicate. Sounds confusing? Have a look at the stub code
and see it you can work out what I try to say.

Regards,

Sai-Lai

-- 
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND