Set error code to 0 for normal TCP disconnection. 85/217885/1
authorSenthil Kumar G S <senthil.gs@samsung.com>
Thu, 31 Oct 2019 05:04:42 +0000 (10:34 +0530)
committerSudipto Bal <sudipto.bal@samsung.com>
Fri, 15 Nov 2019 07:49:01 +0000 (16:49 +0900)
commit37f3677ca981461ff80f0d66dbd23a166442edb0
tree04fee27eac68003a343d07d6ab8b7c37ffc0200e
parent7c2b987e394fcfe851b286a5e5210012c8f8f263
Set error code to 0 for normal TCP disconnection.

g_lastErrorCode is set to 0 to indicate normal session disconnections(recv() returns 0).

Background;
"g_lastErrorCode" is being set as errno when send() returns -1 or recv() returns under 0.
For instance, in case of recv(),
    - normal TCP session disconnect happens when recv() returns 0 len.
    - abnormal TCP session disconnect happens when recv() returns under 0. ( "g_lastErrorCode" is set as errno. )
Let's guess this scenario,
    - abnormal TCP session disconnect => "g_lastErrorCode" is set as X => ...... => retry TCP session connect => ...... => normal TCP session disconnect
From above scenario, then, is "g_lastErrorCode" not changed to default value 0?
I think, it is needed to set "g_lastErrorCode" as default value 0 when normal TCP session connect/disconnect happens.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/595/commits/db79794eab8a1dbbe93d2da4a5deeb4826e22ccb
(cherry-picked from db79794eab8a1dbbe93d2da4a5deeb4826e22ccb)

Change-Id: Iea0d2ed780b9dedee6870a8946c3c5c65d15757c
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
Signed-off-by: Sudipto Bal <sudipto.bal@samsung.com>
resource/csdk/connectivity/src/tcp_adapter/catcpserver.c