From 4daac95e184e7dc6efb4f952d2b194f317f91fe0 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 23 Aug 2001 21:14:56 +0000 Subject: [PATCH] added channel create priority and catch C++ exceptions before they enter C code --- src/ca/access.cpp | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/ca/access.cpp b/src/ca/access.cpp index 34da8d93e..0fda79cc2 100644 --- a/src/ca/access.cpp +++ b/src/ca/access.cpp @@ -206,8 +206,16 @@ extern "C" int epicsShareAPI ca_build_and_connect ( const char *name_str, chtype * ca_search_and_connect() */ extern "C" int epicsShareAPI ca_search_and_connect ( - const char *name_str, chid *chanptr, - caCh *conn_func, void *puser ) + const char * name_str, chid * chanptr, + caCh * conn_func, void * puser ) +{ + return ca_create_channel ( name_str, conn_func, + puser, CA_PRIORITY_DEFAULT, chanptr ); +} + +extern "C" int epicsShareAPI ca_create_channel ( + const char *name_str, caCh * conn_func, void * puser, + capri priority, chid * chanptr ) { oldCAC *pcac; int caStatus = fetchClientContext ( &pcac ); @@ -215,26 +223,31 @@ extern "C" int epicsShareAPI ca_search_and_connect ( return caStatus; } - if ( name_str == NULL || *name_str == '\0' ) { - return ECA_BADSTR; - } - - oldChannelNotify *pChanNotify = new oldChannelNotify ( *pcac, name_str, conn_func, puser ); - if ( ! pChanNotify ) { - return ECA_ALLOCMEM; - } - - if ( pChanNotify->ioAttachOK() ) { - *chanptr = pChanNotify; + try { + oldChannelNotify * pChanNotify = new oldChannelNotify ( + * pcac, name_str, conn_func, puser, priority ); + if ( ! pChanNotify ) { + return ECA_ALLOCMEM; + } // make sure that their chan pointer is set prior to // calling connection call backs + *chanptr = pChanNotify; pChanNotify->initiateConnect (); - return ECA_NORMAL; } - else { - pChanNotify->destroy (); + catch ( cacChannel::badString & ) { + return ECA_BADSTR; + } + catch ( std::bad_alloc & ) { return ECA_ALLOCMEM; } + catch ( cacChannel::badPriority & ) { + return ECA_BADPRIORITY; + } + catch ( ... ) { + return ECA_INTERNAL; + } + + return ECA_NORMAL; } /* @@ -309,7 +322,7 @@ extern "C" int epicsShareAPI ca_array_get ( chtype type, pNotify->cancel (); return ECA_ALLOCMEM; } - catch ( cacChannel::msgBodyCacheTooSmall ) { + catch ( cacChannel::msgBodyCacheTooSmall & ) { pNotify->cancel (); return ECA_TOLARGE; }