Thread: [orbitcpp-list] Re: passing a reference to another process
Status: Beta
Brought to you by:
philipd
From: <MHL...@t-...> - 2000-11-23 20:47:27
|
On 11/22/2000, 03:11:36 Phil Dawes wrote: > Hi Martin, > > Glad you solved your problem - sorry about my reply arriving too > late. > > I agree that it`s unfortunate that this sort of mistake results in > such a nebulus error - can you think of a way we could trap this in > orbitcpp?. > The problem is that all variables xxx_ptr that get initialized from the same reference xxx_var point to a "profile_list". This profile_list is freed when xxx_var is destroyed (unless the reference is duplicated, of course). Now can you look at a xxx_ptr and say whether profile_list still points to a valid memory block or not ? I found my bug because "next" in profile_list was 0x0 but that doesn't necessarily have to be the case. Hmm, perhaps we could define a macro like #ifdef DEBUG #define REFERENCE_IS_VALID(obj) \ if(obj->profile_list) obj->profile_list->data->profile_type = \ obj->profile_list->data->profile_type; #else #define REFERENCE_IS_VALID(obj) #endif and use it in the cpp-stubs before passing obj to the c-stub which in turn passes it to liborbit where the segfault happens. I think this macro should a segfault?! If yes the users attendence should be drawn on the right track! Anyway I think it would be good to add a few comments to client.cc in the test everything. People that start using a new library will first have a look at the examples. Maybe you could modify the program a little so that it stores a refence to a Factory and use it later in another function. Cheers, Martin. |
From: <la...@se...> - 2000-11-30 17:16:40
|
First, is it possible to check if orit has already been initialized? Calling orb =CORBA::ORB_init(argc, argv, "orbit-local-orb") more than once crashes. For now, I will keep a local flag. Perhaps more importanly, if the server has gone down, what is the best way for the client to avoid hanging or crashing on subsequent calls to that server? Is there a way to validate the object such as objectPointer->isWorking() or even objectPointer->wontHang(). Perhaps I can embed and catch an alarm signal before each client call. Any elightenment appreciated. Thanks, -Lance. -- -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- Lance Welsh la...@se... Seascape Communications (650) 327-6890 -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- |
From: Phil D. <ph...@us...> - 2000-12-02 09:59:01
|
Hi Lance, la...@se... writes: > First, is it possible to check if orit has already been initialized? > Calling orb =CORBA::ORB_init(argc, argv, "orbit-local-orb") > more than once crashes. For now, I will keep a local flag. > Err.. not on my machine it doesn't. Which version of orbitcpp / ORBit are you running. > Perhaps more importanly, if the server has gone down, what > is the best way for the client to avoid hanging or crashing on > subsequent calls to that server? Is there a way to validate > the object such as objectPointer->isWorking() or even > objectPointer->wontHang(). Perhaps I can embed and > catch an alarm signal before each client call. > I'm not sure about this one. If orbit is unable to connect to the server you get a CORBA::COMM_FAILURE system exception. However if ORBit has previously connected to the server then you do seem to get a hang. I'll do some experimenting over the weekend... Cheers, Phil |
From: <la...@se...> - 2000-12-07 04:12:37
|
/* * This file was generated by orbit-idl - DO NOT EDIT! */ #include <errno.h> // lance #include <string.h> #include "zone.h" CORBA_char * ZoneModule_ZoneInterface_setTransport(ZoneModule_ZoneInterface _obj, const CORBA_char * ior, CORBA_Environment * ev) { register GIOP_unsigned_long _ORBIT_request_id, _ORBIT_system_exception_minor; register CORBA_completion_status _ORBIT_completion_status; register GIOPSendBuffer *_ORBIT_send_buffer; register GIOPRecvBuffer *_ORBIT_recv_buffer; register GIOPConnection *_cnx; CORBA_char *_ORBIT_retval; register CORBA_unsigned_long _ORBIT_tmpvar_4; CORBA_unsigned_long _ORBIT_tmpvar_5; if (_obj->servant && _obj->vepv && ZoneModule_ZoneInterface__classid) { _ORBIT_retval = ((POA_ZoneModule_ZoneInterface__epv *) _obj-> vepv[ZoneModule_ZoneInterface__classid])->setTransport(_obj-> servant, ior, ev); return _ORBIT_retval; } if (0) return *(&_ORBIT_retval); _cnx = ORBit_object_get_connection(_obj); _ORBIT_retry_request: _ORBIT_send_buffer = NULL; _ORBIT_recv_buffer = NULL; _ORBIT_completion_status = CORBA_COMPLETED_NO; _ORBIT_request_id = GPOINTER_TO_UINT(alloca(0)); { /* marshalling */ static const struct { CORBA_unsigned_long len; char opname[13]; } _ORBIT_operation_name_data = { 13, "setTransport"}; static const struct iovec _ORBIT_operation_vec = { (gpointer) & _ORBIT_operation_name_data, 17 }; register CORBA_unsigned_long _ORBIT_tmpvar_0; CORBA_unsigned_long _ORBIT_tmpvar_1; _ORBIT_send_buffer = giop_send_request_buffer_use(_cnx, NULL, _ORBIT_request_id, CORBA_TRUE, &(_obj->active_profile->object_key_vec), &_ORBIT_operation_vec, &ORBit_default_principal_iovec); _ORBIT_system_exception_minor = ex_CORBA_COMM_FAILURE; if (!_ORBIT_send_buffer) goto _ORBIT_system_exception; _ORBIT_tmpvar_1 = strlen(ior) + 1; giop_message_buffer_do_alignment(GIOP_MESSAGE_BUFFER (_ORBIT_send_buffer), 4); { guchar *_ORBIT_t; _ORBIT_t = alloca(sizeof(_ORBIT_tmpvar_1)); memcpy(_ORBIT_t, &(_ORBIT_tmpvar_1), sizeof(_ORBIT_tmpvar_1)); giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER (_ORBIT_send_buffer), (_ORBIT_t), sizeof(_ORBIT_tmpvar_1)); } giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER(_ORBIT_send_buffer), (ior), sizeof(ior[_ORBIT_tmpvar_0]) * _ORBIT_tmpvar_1); giop_send_buffer_write(_ORBIT_send_buffer); _ORBIT_completion_status = CORBA_COMPLETED_MAYBE; giop_send_buffer_unuse(_ORBIT_send_buffer); _ORBIT_send_buffer = NULL; } { /* demarshalling */ register guchar *_ORBIT_curptr; _ORBIT_recv_buffer = giop_recv_reply_buffer_use_2(_cnx, _ORBIT_request_id, TRUE); if (!_ORBIT_recv_buffer) goto _ORBIT_system_exception; _ORBIT_completion_status = CORBA_COMPLETED_YES; if (_ORBIT_recv_buffer->message.u.reply.reply_status != GIOP_NO_EXCEPTION) goto _ORBIT_msg_exception; _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur; if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); (*((guint32 *) & (_ORBIT_tmpvar_5))) = GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr)); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_5); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5; } else { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); _ORBIT_tmpvar_5 = *((CORBA_unsigned_long *) _ORBIT_curptr); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_5); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5; } giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; _ORBIT_system_exception: CORBA_exception_set_system(ev, _ORBIT_system_exception_minor, _ORBIT_completion_status); giop_recv_buffer_unuse(_ORBIT_recv_buffer); giop_send_buffer_unuse(_ORBIT_send_buffer); return _ORBIT_retval; _ORBIT_msg_exception: if (_ORBIT_recv_buffer->message.u.reply.reply_status == GIOP_LOCATION_FORWARD) { if (_obj->forward_locations != NULL) ORBit_delete_profiles(_obj->forward_locations); _obj->forward_locations = ORBit_demarshal_IOR(_ORBIT_recv_buffer); _cnx = ORBit_object_get_forwarded_connection(_obj); giop_recv_buffer_unuse(_ORBIT_recv_buffer); goto _ORBIT_retry_request; } else { ORBit_handle_exception(_ORBIT_recv_buffer, ev, NULL, _obj->orb); giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; } } } CORBA_char * ZoneModule_ZoneInterface_clearTransport(ZoneModule_ZoneInterface _obj, CORBA_Environment * ev) { register GIOP_unsigned_long _ORBIT_request_id, _ORBIT_system_exception_minor; register CORBA_completion_status _ORBIT_completion_status; register GIOPSendBuffer *_ORBIT_send_buffer; register GIOPRecvBuffer *_ORBIT_recv_buffer; register GIOPConnection *_cnx; CORBA_char *_ORBIT_retval; register CORBA_unsigned_long _ORBIT_tmpvar_2; CORBA_unsigned_long _ORBIT_tmpvar_3; if (_obj->servant && _obj->vepv && ZoneModule_ZoneInterface__classid) { _ORBIT_retval = ((POA_ZoneModule_ZoneInterface__epv *) _obj-> vepv[ZoneModule_ZoneInterface__classid])->clearTransport(_obj-> servant, ev); return _ORBIT_retval; } if (0) return *(&_ORBIT_retval); _cnx = ORBit_object_get_connection(_obj); _ORBIT_retry_request: _ORBIT_send_buffer = NULL; _ORBIT_recv_buffer = NULL; _ORBIT_completion_status = CORBA_COMPLETED_NO; _ORBIT_request_id = GPOINTER_TO_UINT(alloca(0)); { /* marshalling */ static const struct { CORBA_unsigned_long len; char opname[15]; } _ORBIT_operation_name_data = { 15, "clearTransport"}; static const struct iovec _ORBIT_operation_vec = { (gpointer) & _ORBIT_operation_name_data, 19 }; _ORBIT_send_buffer = giop_send_request_buffer_use(_cnx, NULL, _ORBIT_request_id, CORBA_TRUE, &(_obj->active_profile->object_key_vec), &_ORBIT_operation_vec, &ORBit_default_principal_iovec); _ORBIT_system_exception_minor = ex_CORBA_COMM_FAILURE; if (!_ORBIT_send_buffer) goto _ORBIT_system_exception; giop_send_buffer_write(_ORBIT_send_buffer); _ORBIT_completion_status = CORBA_COMPLETED_MAYBE; giop_send_buffer_unuse(_ORBIT_send_buffer); _ORBIT_send_buffer = NULL; } { /* demarshalling */ register guchar *_ORBIT_curptr; _ORBIT_recv_buffer = giop_recv_reply_buffer_use_2(_cnx, _ORBIT_request_id, TRUE); if (!_ORBIT_recv_buffer) goto _ORBIT_system_exception; _ORBIT_completion_status = CORBA_COMPLETED_YES; if (_ORBIT_recv_buffer->message.u.reply.reply_status != GIOP_NO_EXCEPTION) goto _ORBIT_msg_exception; _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur; if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); (*((guint32 *) & (_ORBIT_tmpvar_3))) = GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr)); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_3); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3; } else { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); _ORBIT_tmpvar_3 = *((CORBA_unsigned_long *) _ORBIT_curptr); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_3); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3; } giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; _ORBIT_system_exception: CORBA_exception_set_system(ev, _ORBIT_system_exception_minor, _ORBIT_completion_status); giop_recv_buffer_unuse(_ORBIT_recv_buffer); giop_send_buffer_unuse(_ORBIT_send_buffer); return _ORBIT_retval; _ORBIT_msg_exception: if (_ORBIT_recv_buffer->message.u.reply.reply_status == GIOP_LOCATION_FORWARD) { if (_obj->forward_locations != NULL) ORBit_delete_profiles(_obj->forward_locations); _obj->forward_locations = ORBit_demarshal_IOR(_ORBIT_recv_buffer); _cnx = ORBit_object_get_forwarded_connection(_obj); giop_recv_buffer_unuse(_ORBIT_recv_buffer); goto _ORBIT_retry_request; } else { ORBit_handle_exception(_ORBIT_recv_buffer, ev, NULL, _obj->orb); giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; } } } CORBA_char * ZoneModule_ZoneInterface_getTransport(ZoneModule_ZoneInterface _obj, CORBA_Environment * ev) { register GIOP_unsigned_long _ORBIT_request_id, _ORBIT_system_exception_minor; register CORBA_completion_status _ORBIT_completion_status; register GIOPSendBuffer *_ORBIT_send_buffer; register GIOPRecvBuffer *_ORBIT_recv_buffer; register GIOPConnection *_cnx; CORBA_char *_ORBIT_retval; register CORBA_unsigned_long _ORBIT_tmpvar_2; CORBA_unsigned_long _ORBIT_tmpvar_3; if (_obj->servant && _obj->vepv && ZoneModule_ZoneInterface__classid) { _ORBIT_retval = ((POA_ZoneModule_ZoneInterface__epv *) _obj-> vepv[ZoneModule_ZoneInterface__classid])->getTransport(_obj-> servant, ev); return _ORBIT_retval; } if (0) return *(&_ORBIT_retval); _cnx = ORBit_object_get_connection(_obj); _ORBIT_retry_request: _ORBIT_send_buffer = NULL; _ORBIT_recv_buffer = NULL; _ORBIT_completion_status = CORBA_COMPLETED_NO; _ORBIT_request_id = GPOINTER_TO_UINT(alloca(0)); { /* marshalling */ static const struct { CORBA_unsigned_long len; char opname[13]; } _ORBIT_operation_name_data = { 13, "getTransport"}; static const struct iovec _ORBIT_operation_vec = { (gpointer) & _ORBIT_operation_name_data, 17 }; _ORBIT_send_buffer = giop_send_request_buffer_use(_cnx, NULL, _ORBIT_request_id, CORBA_TRUE, &(_obj->active_profile->object_key_vec), &_ORBIT_operation_vec, &ORBit_default_principal_iovec); _ORBIT_system_exception_minor = ex_CORBA_COMM_FAILURE; if (!_ORBIT_send_buffer) goto _ORBIT_system_exception; errno=0 ; // lance giop_send_buffer_write(_ORBIT_send_buffer); if (errno) // lance goto _ORBIT_system_exception; // lance _ORBIT_completion_status = CORBA_COMPLETED_MAYBE; giop_send_buffer_unuse(_ORBIT_send_buffer); _ORBIT_send_buffer = NULL; } { /* demarshalling */ register guchar *_ORBIT_curptr; _ORBIT_recv_buffer = giop_recv_reply_buffer_use_2(_cnx, _ORBIT_request_id, TRUE); if (!_ORBIT_recv_buffer) goto _ORBIT_system_exception; _ORBIT_completion_status = CORBA_COMPLETED_YES; if (_ORBIT_recv_buffer->message.u.reply.reply_status != GIOP_NO_EXCEPTION) goto _ORBIT_msg_exception; _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur; if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); (*((guint32 *) & (_ORBIT_tmpvar_3))) = GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr)); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_3); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3; } else { _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4); _ORBIT_tmpvar_3 = *((CORBA_unsigned_long *) _ORBIT_curptr); _ORBIT_curptr += 4; _ORBIT_retval = CORBA_string_alloc(_ORBIT_tmpvar_3); memcpy(_ORBIT_retval, _ORBIT_curptr, sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3); _ORBIT_curptr += sizeof(_ORBIT_retval[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3; } giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; _ORBIT_system_exception: CORBA_exception_set_system(ev, _ORBIT_system_exception_minor, _ORBIT_completion_status); giop_recv_buffer_unuse(_ORBIT_recv_buffer); giop_send_buffer_unuse(_ORBIT_send_buffer); return _ORBIT_retval; _ORBIT_msg_exception: if (_ORBIT_recv_buffer->message.u.reply.reply_status == GIOP_LOCATION_FORWARD) { if (_obj->forward_locations != NULL) ORBit_delete_profiles(_obj->forward_locations); _obj->forward_locations = ORBit_demarshal_IOR(_ORBIT_recv_buffer); _cnx = ORBit_object_get_forwarded_connection(_obj); giop_recv_buffer_unuse(_ORBIT_recv_buffer); goto _ORBIT_retry_request; } else { ORBit_handle_exception(_ORBIT_recv_buffer, ev, NULL, _obj->orb); giop_recv_buffer_unuse(_ORBIT_recv_buffer); return _ORBIT_retval; } } } |
From: <la...@se...> - 2000-12-09 05:05:32
|
Phil Dawes wrote: > > Perhaps more importanly, if the server has gone down, what > > is the best way for the client to avoid hanging or crashing on > > subsequent calls to that server? Is there a way to validate > > the object such as objectPointer->isWorking() or even > > objectPointer->wontHang(). Perhaps I can embed and > > catch an alarm signal before each client call. > > > > I'm not sure about this one. If orbit is unable to connect to the > server you get a CORBA::COMM_FAILURE system exception. However if > ORBit has previously connected to the server then you do seem to get a > hang. I'll do some experimenting over the weekend... In trying to unbemuse myself how to use orbit in a fault-tolerant way on linux, I've discovered where the client hangs when the server dies. On any idl-defined function call, the client permenantly hangs when calling 'giop_recv_reply_buffer_use_2' in the <name>-stubs.c file where it is apparently expecting to receive a reply after having sent a write via: 'giop_send_buffer_write' where the write failed (but the error is not checked. This hang can be avoided by checking 'errno' after 'giop_send_buffer_write' then throwing an exception: errno=0 ; // lance giop_send_buffer_write(_ORBIT_send_buffer); if (errno) // lance goto _ORBIT_system_exception; // lance which works well but needs to be part of orbit-idl's 'C'-code generation (and has nothing to do with orbitcpp other than be used by it). ... please standby while I download ORBit-0.5.5 ... I've found the code that generates 'giop_recv_reply_buffer_use_2': #ifdef BACKWARDS_COMPAT_0_4 fprintf(ci->fh, "giop_send_buffer_write(_ORBIT_send_buffer);\n"); #else fprintf(ci->fh, "if(giop_send_buffer_write(_ORBIT_send_buffer)) goto _ORBIT_system_exception;\n"); #endif Wow. I love open source. Gives me all sorts of new ways to spend my Friday nights! Now I change ./ORBit-0.5.5/src/orb/orbit.h.in: /* #define BACKWARDS_COMPAT_0_4 */ /* #undef NOT_BACKWARDS_COMPAT_0_4 */ #undef BACKWARDS_COMPAT_0_4 #define NOT_BACKWARDS_COMPAT_0_4 followed by a 'make clean' and that almost works but alas that still leaves ./ORBit-0.5.5/src/orbit-idl-compiler/backends/c/ which appears to not be a generated file with a '#define BACKWARDS_COMPAT_0_4'. Forcing that change, a remake and install should finally yield the desirable results of generating a <name>-stubs.c file which checks the return value of giop_send_buffer_write for an error and appropriately throws an exception. Ahh, but it doesn't - my previous orbit was installed in '/usr' where this 'make install' went to '/usr/local'. A quick run of './configure --prefix=/usr' and there's the fix! Perhaps someone in the ORBit community can tell me how thin the ground is when not defining 'BACKWARDS_COMPAT_0_4'? Perhaps I should have simple made the modification locally to orbit-idl-c-stubs.c rather then the sweeping undefine. And I hope this is of use to someone else. Thanks, -Lance. -- -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- Lance Welsh la...@se... Seascape Communications (650) 327-6890 -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- |