summaryrefslogtreecommitdiffstats
path: root/src/phFriNfc_LlcpTransport_Connection.c
diff options
context:
space:
mode:
authorArnaud Ferir <arnaud.ferir@trusted-logic.com>2011-01-14 09:59:35 +0100
committerNick Pelly <npelly@google.com>2011-01-18 15:34:09 -0800
commit28235f8b29ef8cc368dd132080245778cdf704cc (patch)
tree7e99f593f14a9132d2fa939b304a64b74ad9b953 /src/phFriNfc_LlcpTransport_Connection.c
parent407d793f3038222dac95651866b99cd064e214eb (diff)
downloadexternal_libnfc-nxp-28235f8b29ef8cc368dd132080245778cdf704cc.zip
external_libnfc-nxp-28235f8b29ef8cc368dd132080245778cdf704cc.tar.gz
external_libnfc-nxp-28235f8b29ef8cc368dd132080245778cdf704cc.tar.bz2
Erase callback when function returns immediately.
This should avoid calling a irrelevant callback at abort. Change-Id: Ied8d54268613f248fd505d4b25d0ab8a0905a336
Diffstat (limited to 'src/phFriNfc_LlcpTransport_Connection.c')
-rw-r--r--src/phFriNfc_LlcpTransport_Connection.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/phFriNfc_LlcpTransport_Connection.c b/src/phFriNfc_LlcpTransport_Connection.c
index 95b5527..fff63b4 100644
--- a/src/phFriNfc_LlcpTransport_Connection.c
+++ b/src/phFriNfc_LlcpTransport_Connection.c
@@ -2081,11 +2081,11 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Accept(phFriNfc_LlcpTranspor
{
/* Call the CB */
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
- return status;
+ goto clean_and_return;
}
}
- /* Recive Window */
+ /* Receive Window */
if(pLlcpSocket->sSocketOption.rw != PHFRINFC_LLCP_RW_DEFAULT)
{
/* Encode RW value */
@@ -2101,7 +2101,7 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Accept(phFriNfc_LlcpTranspor
{
/* Call the CB */
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
- return status;
+ goto clean_and_return;
}
}
@@ -2143,6 +2143,15 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Accept(phFriNfc_LlcpTranspor
phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
pLlcpSocket->psTransport);
}
+
+clean_and_return:
+ if(status != NFCSTATUS_PENDING)
+ {
+ LLCP_PRINT("Release Accept callback");
+ pLlcpSocket->pfSocketAccept_Cb = NULL;
+ pLlcpSocket->pAcceptContext = NULL;
+ }
+
return status;
}
@@ -2257,11 +2266,12 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransp
miux);
if(status != NFCSTATUS_SUCCESS)
{
- return status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
+ status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
+ goto clean_and_return;
}
}
- /* Recive Window */
+ /* Receive Window */
if(pLlcpSocket->sSocketOption.rw != PHFRINFC_LLCP_RW_DEFAULT)
{
/* Encode RW value */
@@ -2276,6 +2286,7 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransp
if(status != NFCSTATUS_SUCCESS)
{
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
+ goto clean_and_return;
}
}
@@ -2291,10 +2302,11 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransp
if(status != NFCSTATUS_SUCCESS)
{
status = PHNFCSTVAL(CID_FRI_NFC_LLCP_TRANSPORT, NFCSTATUS_FAILED);
+ goto clean_and_return;
}
}
- /* Test if a send is pending */
+ /* Test if a send is pending */
if(pLlcpSocket->psTransport->bSendPending == TRUE)
{
pLlcpSocket->bSocketConnectPending = TRUE;
@@ -2326,6 +2338,14 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Connect( phFriNfc_LlcpTransp
pLlcpSocket->psTransport);
}
+clean_and_return:
+ if(status != NFCSTATUS_PENDING)
+ {
+ LLCP_PRINT("Release Connect callback");
+ pLlcpSocket->pfSocketConnect_Cb = NULL;
+ pLlcpSocket->pConnectContext = NULL;
+ }
+
return status;
}
@@ -2423,7 +2443,14 @@ NFCSTATUS phLibNfc_LlcpTransport_ConnectionOriented_Disconnect(phFriNfc_LlcpTran
NULL,
phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
pLlcpSocket->psTransport);
+ if(status != NFCSTATUS_PENDING)
+ {
+ LLCP_PRINT("Release Disconnect callback");
+ pLlcpSocket->pfSocketConnect_Cb = NULL;
+ pLlcpSocket->pConnectContext = NULL;
+ }
}
+
return status;
}
@@ -2621,6 +2648,12 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Send(phFriNfc_LlcpTransport_
psBuffer,
phFriNfc_LlcpTransport_ConnectionOriented_SendLlcp_CB,
pLlcpSocket->psTransport);
+ if(status != NFCSTATUS_PENDING)
+ {
+ LLCP_PRINT("Release Send callback");
+ pLlcpSocket->pfSocketSend_Cb = NULL;
+ pLlcpSocket->pSendContext = NULL;
+ }
/* Update VS */
pLlcpSocket->socket_VS = (pLlcpSocket->socket_VS+1)%16;
@@ -2827,6 +2860,14 @@ NFCSTATUS phFriNfc_LlcpTransport_ConnectionOriented_Recv( phFriNfc_LlcpTransport
}
}
+ if(status != NFCSTATUS_PENDING)
+ {
+ /* Note: The receive callback must be released to avoid being called at abort */
+ LLCP_PRINT("Release Receive callback");
+ pLlcpSocket->pfSocketRecv_Cb = NULL;
+ pLlcpSocket->pRecvContext = NULL;
+ }
+
return status;
}