This repository was archived by the owner on Jul 22, 2023. It is now read-only.
Commit b556488
committed
Fix faulty io net error handling code in posix BSP
Basically, when the SDK allocates the structure in which it will
store the socket descriptor it opens when connecting to the iotcore
server, it initializes it to 0. If during the process of creating the
socket, the posix BSP routine (iotc_bsp_io_net_socket_connect) that
creates the socket can’t resolve the iotcore server name, it returns
an error (leaving the socket descriptor field initialized to 0). In
turn, the io net routine (iotc_io_net_layer_connect) that itself
called iotc_bsp_io_net_socket_connect, on seeing the error, will then
execute its error handling code that itself ends up calling the io
net routine iotc_io_net_layer_close_externally that then calls the
posix BSP iotc_bsp_io_net_close_socket routine. The posix BSP
iotc_bsp_io_net_close_socket routine then blindly closes socket
descriptor 0 (since this is what the data structure tracking the
socket descriptor is still initialized to since no socket was ever
successfully opened).
Files modified:
src/bsp/platform/posix/iotc_bsp_io_net_posix.c
- always set *iotc_socket to -1 before attempting to connect or after
closing the socket and always check that *iotc_socket is not -1
before attempting to close it in iotc_bsp_io_net_close_socket().1 parent 09f84c8 commit b556488
1 file changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
| |||
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
200 | 208 | | |
201 | 209 | | |
202 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
203 | 216 | | |
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
207 | | - | |
| 220 | + | |
208 | 221 | | |
209 | 222 | | |
210 | 223 | | |
| |||
0 commit comments