summaryrefslogtreecommitdiff
path: root/src/daemon/dlt_daemon_event_handler.c
diff options
context:
space:
mode:
authorVo Trung Chi <Chi.VoTrung@vn.bosch.com>2019-05-15 16:16:30 +0700
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-06-18 17:22:09 +0900
commitc6be4affa0b817437e5c11ced065195459818be3 (patch)
tree6cc1b30e8c61fb7dc01634e22120054640a242fa /src/daemon/dlt_daemon_event_handler.c
parent3580c5640c5578f508e93a8a851231b389d327cd (diff)
downloadDLT-daemon-c6be4affa0b817437e5c11ced065195459818be3.tar.gz
daemon: Loop for client fds
In dlt_daemon_client_send_all_multiple(), while in the loop, the connection to client may be destroyed by recursive call to dlt_daemon_close_socket(). So in some scenario we still use the removed connection, which is unexpected behavior. Solution: loop on the fds array and find the client connection corresponds to. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
Diffstat (limited to 'src/daemon/dlt_daemon_event_handler.c')
-rw-r--r--src/daemon/dlt_daemon_event_handler.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 895a896..38aa022 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -285,14 +285,15 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
*
* @return The found connection pointer, NULL otherwise.
*/
-DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev,
- int fd)
+DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev, int fd)
{
-
DltConnection *temp = ev->connections;
- while ((temp != NULL) && (temp->receiver->fd != fd))
+ while (temp != NULL) {
+ if ((temp->receiver != NULL) && (temp->receiver->fd == fd))
+ return temp;
temp = temp->next;
+ }
return temp;
}