From a4fcecf39743948da4095868e36f910d8d259caa Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 21 Mar 2005 23:57:28 +0000 Subject: [PATCH] fixed bug where put payload was byte swapped twice --- src/cas/generic/casStrmClient.cc | 33 ++++++++++++++++++++------------ src/cas/generic/casStrmClient.h | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/cas/generic/casStrmClient.cc b/src/cas/generic/casStrmClient.cc index 0265129f7..ba1a1ff04 100644 --- a/src/cas/generic/casStrmClient.cc +++ b/src/cas/generic/casStrmClient.cc @@ -80,7 +80,8 @@ casStrmClient::casStrmClient ( caServerI & cas, clientBufMemoryManager & mgrIn ) pUserName ( 0 ), pHostName ( 0 ), incommingBytesToDrain ( 0 ), - minor_version_number ( 0 ) + minor_version_number ( 0 ), + payloadNeedsByteSwap ( true ) { this->pHostName = new char [1u]; *this->pHostName = '\0'; @@ -1973,12 +1974,16 @@ caStatus casStrmClient::write() } #ifdef CONVERSION_REQUIRED - /* use type as index into conversion jumptable */ - (* cac_dbr_cvrt[pHdr->m_dataType]) - ( this->ctx.getData(), - this->ctx.getData(), - false, /* net -> host format */ - pHdr->m_count); + // dont byte swap twice + if ( this->payloadNeedsByteSwap ) { + /* use type as index into conversion jumptable */ + (* cac_dbr_cvrt[pHdr->m_dataType]) + ( this->ctx.getData(), + this->ctx.getData(), + false, /* net -> host format */ + pHdr->m_count); + this->payloadNeedsByteSwap = false; + } #endif // @@ -2003,17 +2008,21 @@ caStatus casStrmClient::write() // indicating so (and vise versa) // if ( this->userStartedAsyncIO ) { - if (status!=S_casApp_asyncCompletion) { + if ( status != S_casApp_asyncCompletion ) { fprintf(stderr, "Application returned %d from casChannel::write() - expected S_casApp_asyncCompletion\n", status); status = S_casApp_asyncCompletion; } + this->payloadNeedsByteSwap = true; } - else if ( status == S_casApp_asyncCompletion ) { - status = S_cas_badParameter; - errMessage ( status, - "- expected asynch IO creation from casChannel::write()" ); + else if ( status != S_casApp_postponeAsyncIO ) { + if ( status == S_casApp_asyncCompletion ) { + status = S_cas_badParameter; + errMessage ( status, + "- expected asynch IO creation from casChannel::write()" ); + } + this->payloadNeedsByteSwap = true; } return status; diff --git a/src/cas/generic/casStrmClient.h b/src/cas/generic/casStrmClient.h index 8490f6796..49a8abfa2 100644 --- a/src/cas/generic/casStrmClient.h +++ b/src/cas/generic/casStrmClient.h @@ -64,6 +64,7 @@ private: char * pHostName; unsigned incommingBytesToDrain; ca_uint16_t minor_version_number; + bool payloadNeedsByteSwap; caStatus createChannel ( const char * pName ); caStatus verifyRequest ( casChannelI * & pChan );