From da78e01e8955448ed1e7cb384a37ddddcf6f0ca0 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 31 Jul 2016 19:49:08 -0400 Subject: [PATCH] rsrv: remove !CA_V44() code Remove code supporting deprecated CA minor versions < 3 --- src/ioc/rsrv/camessage.c | 308 +++++++++++---------------------------- 1 file changed, 89 insertions(+), 219 deletions(-) diff --git a/src/ioc/rsrv/camessage.c b/src/ioc/rsrv/camessage.c index 769389d50..720289647 100644 --- a/src/ioc/rsrv/camessage.c +++ b/src/ioc/rsrv/camessage.c @@ -452,16 +452,6 @@ static void no_read_access_event ( struct client *pClient, char *pPayloadOut; int status; - /* - * continue to return an exception - * on failure to pre v41 clients - */ - if ( ! CA_V41 ( pClient->minor_version_number ) ) { - send_err ( &pevext->msg, ECA_GETFAIL, pClient, - RECORD_NAME ( pevext->pciu->dbch ) ); - return; - } - /* * New clients recv the status of the * operation directly to the @@ -501,7 +491,6 @@ static void read_reply ( void *pArg, struct dbChannel *dbch, struct channel_in_use *pciu = pevext->pciu; const int readAccess = asCheckGet ( pciu->asClientPVT ); int status; - int v41; int autosize; int local_fl = 0; long item_count; @@ -510,23 +499,7 @@ static void read_reply ( void *pArg, struct dbChannel *dbch, SEND_LOCK ( pClient ); - /* - * New clients recv the status of the - * operation directly to the - * event/put/get callback. - * - * The m_cid field in the protocol - * header is abused to carry the status, - * but get calls still use the - * m_cid field to identify the channel - */ - v41 = CA_V41 ( pClient->minor_version_number ); - if ( v41 ) { - cid = ECA_NORMAL; - } - else { - cid = pciu->cid; - } + cid = ECA_NORMAL; /* If the client has requested a zero element count we interpret this as a * request for all avaiable elements. In this case we initialise the @@ -577,35 +550,22 @@ static void read_reply ( void *pArg, struct dbChannel *dbch, if (local_fl) db_delete_field_log(pfl); if ( status < 0 ) { - /* - * I cant wait to redesign this protocol from scratch! - */ - if ( ! v41 ) { - /* - * old client & plain get - * continue to return an exception - * on failure - */ - send_err ( &pevext->msg, ECA_GETFAIL, pClient, RECORD_NAME ( dbch ) ); - } - else { - /* New clients recv the status of the operation directly to the - * event/put/get callback. - * - * Fetched value is set to zero in case they use it even when the - * status indicates failure -- unless the client selected autosizing - * data, in which case they'd better know what they're doing! - * - * The m_cid field in the protocol header is abused to carry the - * status */ - if (autosize) { - payload_size = dbr_size_n(pevext->msg.m_dataType, 0); - cas_set_header_count(pClient, 0); - } - memset ( pPayload, 0, payload_size ); - cas_set_header_cid ( pClient, ECA_GETFAIL ); - cas_commit_msg ( pClient, payload_size ); + /* Clients recv the status of the operation directly to the + * event/put/get callback. (from CA_V41()) + * + * Fetched value is set to zero in case they use it even when the + * status indicates failure -- unless the client selected autosizing + * data, in which case they'd better know what they're doing! + * + * The m_cid field in the protocol header is abused to carry the + * status */ + if (autosize) { + payload_size = dbr_size_n(pevext->msg.m_dataType, 0); + cas_set_header_count(pClient, 0); } + memset ( pPayload, 0, payload_size ); + cas_set_header_cid ( pClient, ECA_GETFAIL ); + cas_commit_msg ( pClient, payload_size ); } else { int cacStatus = caNetConvert ( @@ -655,7 +615,6 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p ca_uint32_t payloadSize; void *pPayload; int status; - int v41; int local_fl = 0; db_field_log *pfl = NULL; @@ -686,14 +645,8 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p /* * verify read access */ - v41 = CA_V41 ( pClient->minor_version_number ); if ( ! readAccess ) { - if ( v41 ) { - status = ECA_NORDACCESS; - } - else{ - status = ECA_GETFAIL; - } + status = ECA_NORDACCESS; send_err ( mp, status, pClient, RECORD_NAME ( pciu->dbch ) ); SEND_UNLOCK ( pClient ); @@ -795,7 +748,6 @@ static int write_action ( caHdrLargeArray *mp, void *pPayload, struct client *client ) { struct channel_in_use *pciu; - int v41; int status; long dbStatus; void *asWritePvt; @@ -807,13 +759,7 @@ static int write_action ( caHdrLargeArray *mp, } if(!rsrvCheckPut(pciu)){ - v41 = CA_V41(client->minor_version_number); - if(v41){ - status = ECA_NOWTACCESS; - } - else{ - status = ECA_PUTFAIL; - } + status = ECA_NOWTACCESS; SEND_LOCK(client); send_err( mp, @@ -1178,19 +1124,10 @@ static void casAccessRightsCB(ASCLIENTPVT ascpvt, asClientStatus type) static void access_rights_reply ( struct channel_in_use * pciu ) { unsigned ar; - int v41; int status; assert ( pciu->client->proto!=IPPROTO_UDP ); - /* - * noop if this is an old client - */ - v41 = CA_V41 ( pciu->client->minor_version_number ); - if ( ! v41 ){ - return; - } - ar = 0; /* none */ if ( asCheckGet ( pciu->asClientPVT ) ) { ar |= CA_PROTO_ACCESS_RIGHT_READ; @@ -1217,39 +1154,38 @@ static void access_rights_reply ( struct channel_in_use * pciu ) */ static void claim_ciu_reply ( struct channel_in_use * pciu ) { - int v42 = CA_V42 ( pciu->client->minor_version_number ); + int status; + ca_uint32_t nElem; + long dbElem; + access_rights_reply ( pciu ); - if ( v42 ) { - int status; - ca_uint32_t nElem; - long dbElem; - SEND_LOCK ( pciu->client ); - dbElem = dbChannelFinalElements(pciu->dbch); - if ( dbElem < 0 ) { - nElem = 0; - } - else { - if ( ! CA_V49 ( pciu->client->minor_version_number ) ) { - if ( dbElem >= 0xffff ) { - nElem = 0xfffe; - } - else { - nElem = (ca_uint32_t) dbElem; - } + + SEND_LOCK ( pciu->client ); + dbElem = dbChannelFinalElements(pciu->dbch); + if ( dbElem < 0 ) { + nElem = 0; + } + else { + if ( ! CA_V49 ( pciu->client->minor_version_number ) ) { + if ( dbElem >= 0xffff ) { + nElem = 0xfffe; } else { nElem = (ca_uint32_t) dbElem; } } - status = cas_copy_in_header ( - pciu->client, CA_PROTO_CREATE_CHAN, 0u, - dbChannelFinalCAType(pciu->dbch), nElem, pciu->cid, - pciu->sid, NULL ); - if ( status == ECA_NORMAL ) { - cas_commit_msg ( pciu->client, 0u ); + else { + nElem = (ca_uint32_t) dbElem; } - SEND_UNLOCK(pciu->client); } + status = cas_copy_in_header ( + pciu->client, CA_PROTO_CREATE_CHAN, 0u, + dbChannelFinalCAType(pciu->dbch), nElem, pciu->cid, + pciu->sid, NULL ); + if ( status == ECA_NORMAL ) { + cas_commit_msg ( pciu->client, 0u ); + } + SEND_UNLOCK(pciu->client); } /* @@ -1269,89 +1205,51 @@ static int claim_ciu_action ( caHdrLargeArray *mp, */ client->minor_version_number = mp->m_available; - if (CA_V44(client->minor_version_number)) { - struct dbChannel *dbch; - char *pName = (char *) pPayload; + if (!CA_V44(client->minor_version_number)) + return RSRV_ERROR; /* shouldn't actually get here due to VSUPPORTED test in camessage() */ - /* - * check the sanity of the message - */ - if (mp->m_postsize<=1) { - log_header ( "empty PV name in UDP search request?", - client, mp, pPayload, 0 ); - return RSRV_OK; - } - pName[mp->m_postsize-1] = '\0'; + struct dbChannel *dbch; + char *pName = (char *) pPayload; - dbch = dbChannel_create (pName); - if (!dbch) { - SEND_LOCK(client); - status = cas_copy_in_header ( client, - CA_PROTO_CREATE_CH_FAIL, 0, 0, 0, mp->m_cid, 0, NULL ); - if (status == ECA_NORMAL) - cas_commit_msg ( client, 0u ); - SEND_UNLOCK(client); - return RSRV_OK; - } - - DLOG ( 2, ("CAS: claim_ciu_action found '%s', type %d, count %d\n", - pName, dbChannelCAType(dbch), dbChannelElements(dbch)) ); - - pciu = casCreateChannel ( - client, - dbch, - mp->m_cid); - if (!pciu) { - log_header ("no memory to create new channel", - client, mp, pPayload, 0); - SEND_LOCK(client); - send_err(mp, - ECA_ALLOCMEM, - client, - RECORD_NAME(dbch)); - SEND_UNLOCK(client); - dbChannelDelete(dbch); - return RSRV_ERROR; - } + /* + * check the sanity of the message + */ + if (mp->m_postsize<=1) { + log_header ( "empty PV name in UDP search request?", + client, mp, pPayload, 0 ); + return RSRV_OK; } - else { - epicsMutexMustLock(client->chanListLock); - /* - * clients which dont claim their - * channel in use block prior to - * timeout must reconnect - */ - pciu = MPTOPCIU(mp); - if(!pciu){ - errlogPrintf("CAS: client timeout disconnect id=%d\n", - mp->m_cid); - epicsMutexUnlock(client->chanListLock); - SEND_LOCK(client); - send_err( - mp, - ECA_INTERNAL, - client, - "old connect protocol timed out"); - SEND_UNLOCK(client); - return RSRV_ERROR; - } + pName[mp->m_postsize-1] = '\0'; - /* - * remove channel in use block from - * the UDP client where it could time - * out and place it on the client - * who is claiming it - */ - ellDelete( - &client->chanList, - &pciu->node); - epicsMutexUnlock(client->chanListLock); + dbch = dbChannel_create (pName); + if (!dbch) { + SEND_LOCK(client); + status = cas_copy_in_header ( client, + CA_PROTO_CREATE_CH_FAIL, 0, 0, 0, mp->m_cid, 0, NULL ); + if (status == ECA_NORMAL) + cas_commit_msg ( client, 0u ); + SEND_UNLOCK(client); + return RSRV_OK; + } - epicsMutexMustLock(client->chanListLock); - pciu->state = rsrvCS_pendConnectResp; - pciu->client = client; - ellAdd(&client->chanList, &pciu->node); - epicsMutexUnlock(client->chanListLock); + DLOG ( 2, ("CAS: claim_ciu_action found '%s', type %d, count %d\n", + pName, dbChannelCAType(dbch), dbChannelElements(dbch)) ); + + pciu = casCreateChannel ( + client, + dbch, + mp->m_cid); + if (!pciu) { + log_header ("no memory to create new channel", + client, mp, pPayload, 0); + SEND_LOCK(client); + send_err(mp, + ECA_ALLOCMEM, + client, + RECORD_NAME(dbch)); + SEND_UNLOCK(client); + dbChannelDelete(dbch); + return RSRV_ERROR; } /* @@ -2211,13 +2109,11 @@ static int udp_version_action ( caHdrLargeArray *mp, void *pPayload, struct clie return RSRV_ERROR; } - if ( mp->m_count != 0 ) { - if ( CA_V411 ( mp->m_count ) ) { - client->seqNoOfReq = mp->m_cid; - } - else { - client->seqNoOfReq = 0; - } + if ( CA_V411 ( mp->m_count ) ) { + client->seqNoOfReq = mp->m_cid; + } + else { + client->seqNoOfReq = 0; } return RSRV_OK; } @@ -2309,34 +2205,8 @@ static int search_reply_udp ( caHdrLargeArray *mp, void *pPayload, struct client type = ca_server_port; } else { - struct dbChannel *dbch; - struct channel_in_use *pchannel; - - dbch = dbChannel_create(pName); - if (!dbch) { - DLOG ( 2, ( "CAS: dbChannel Test of \"%s\" OK but Create failed\n", pName ) ); - return RSRV_OK; - } - pchannel = casCreateChannel ( client, dbch, mp->m_cid ); - if (!pchannel) { - SEND_LOCK(client); - send_err ( mp, ECA_ALLOCMEM, client, - RECORD_NAME ( dbch ) ); - SEND_UNLOCK ( client ); - dbChannelDelete(dbch); - return RSRV_OK; - } - sid = pchannel->sid; - if ( dbChannelFinalElements(dbch) < 0 ) { - count = 0; - } - else if ( dbChannelFinalElements(dbch) > 0xffff ) { - count = 0xfffe; - } - else { - count = (ca_uint16_t) dbChannelFinalElements(dbch); - } - type = (ca_uint16_t) dbChannelFinalCAType(dbch); + /* shouldn't actually get here due to VSUPPORTED test */ + return RSRV_ERROR; } SEND_LOCK ( client );