diff options
author | RalphNiemeyer <rniemeyer@de.adit-jv.com> | 2017-03-23 09:58:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-23 09:58:59 +0100 |
commit | 49d5962d3960eabc989796d4e3236a55c14618e6 (patch) | |
tree | a61dd79be59d2346be0c3614ed1f062f1ca147e2 /src/daemon/dlt_daemon_connection.c | |
parent | a961dba0013ed2119aa719546c63212459753549 (diff) | |
parent | 0ce6e68d8835b13aa6be52ffdf2d81e1170a3834 (diff) | |
download | DLT-daemon-49d5962d3960eabc989796d4e3236a55c14618e6.tar.gz |
Merge pull request #5 from clipka/devel_connection_handling_fixes
Daemon connection handling fixes
Diffstat (limited to 'src/daemon/dlt_daemon_connection.c')
-rw-r--r-- | src/daemon/dlt_daemon_connection.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c index 51f975d..8d2aa67 100644 --- a/src/daemon/dlt_daemon_connection.c +++ b/src/daemon/dlt_daemon_connection.c @@ -47,6 +47,8 @@ #include "dlt_common.h" #include "dlt_gateway.h" +static DltConnectionId connectionId; + /** @brief Generic sending function. * * We manage different type of connection which have similar send/write @@ -171,6 +173,7 @@ STATIC void dlt_connection_destroy_receiver(DltConnection *con) default: (void) dlt_receiver_free(con->receiver); free(con->receiver); + con->receiver = NULL; break; } } @@ -318,8 +321,12 @@ void *dlt_connection_get_callback(DltConnection *con) */ void dlt_connection_destroy(DltConnection *to_destroy) { + to_destroy->id = 0; close(to_destroy->receiver->fd); dlt_connection_destroy_receiver(to_destroy); + /* connection pointer might be in epoll queue and used even after destroying + * it. To make sure it is not used anymore, connection type is invalidated */ + to_destroy->type = DLT_CONNECTION_TYPE_MAX; free(to_destroy); } @@ -384,6 +391,14 @@ int dlt_connection_create(DltDaemonLocal *daemon_local, return -1; } + /* We are single threaded no need for protection. */ + temp->id = connectionId++; + if (!temp->id) + { + /* Skipping 0 */ + temp->id = connectionId++; + } + temp->type = type; temp->status = ACTIVE; |