Bugfix/datalink init and cleanup consistency#1380
Merged
Merged
Conversation
…pps application sources where dlenv_init() is also present.
…default datalink initialization in protocol-specific init functions. Skip default datalink init and task when task callback is set.
…in functions to ensure consistency across applications
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make datalink initialization and teardown more consistent across the stack by centralizing cleanup behind dlenv_cleanup() and by decoupling bacnet_port_task() from compile-time datalink selection via a configurable periodic-task callback.
Changes:
- Added
dlenv_cleanup()(wrapper arounddatalink_cleanup()) and updated many apps to register it withatexit()instead of callingdatalink_cleanup()directly. - Added
bacnet_port_task_callback_set()and refactoredbacnet_port_task()to invoke a configured callback (with defaults set duringbacnet_port_init()when no custom callback is provided). - Adjusted
server-basicandblinktapps to initialize viadlenv_init(), register cleanup, and route periodic maintenance viabacnet_port_task_callback_set(dlenv_maintenance_timer).
Reviewed changes
Copilot reviewed 59 out of 59 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/bacnet/datalink/dlenv.h | Exports new dlenv_cleanup() API. |
| src/bacnet/datalink/dlenv.c | Implements dlenv_cleanup() as a datalink_cleanup() wrapper. |
| src/bacnet/basic/server/bacnet_port.h | Adds exported bacnet_port_task_callback_set() declaration. |
| src/bacnet/basic/server/bacnet_port.c | Introduces callback-driven bacnet_port_task() and default callback wiring in bacnet_port_init(). |
| src/bacnet/basic/server/bacnet_port_mstp.c | Removes direct datalink init from Network Port object init routine. |
| src/bacnet/basic/server/bacnet_port_ipv6.c | Removes direct datalink init from Network Port object init routine. |
| src/bacnet/basic/server/bacnet_port_ipv4.c | Removes direct datalink init from Network Port object init routine. |
| src/bacnet/basic/server/bacnet_port_bzll.c | Removes direct datalink init from Network Port object init routine. |
| apps/you-are/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/writepropm/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/writeprop/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/writegroup/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
| apps/writefile/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/writebdt/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/whoisrouter/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/whois/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/whohas/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/who-am-i/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/whatisnetnum/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/uptransfer/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/uevent/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/ucov/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
| apps/timesync/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/server/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/server-mini/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/server-discover/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/server-client/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
| apps/server-basic/main.c | Uses dlenv_init() + dlenv_cleanup() and routes periodic maintenance via bacnet_port_task_callback_set(dlenv_maintenance_timer). |
| apps/scov/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/sc-hub/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/remove-list-element/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/reinit/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readrange/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readpropm/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readprop/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readfile/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readfdt/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/readbdt/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/ptransfer/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/piface/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/netnumis/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/modbus-gateway/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/initrouter/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/iamrouter/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
| apps/iam/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/getevent/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/gateway2/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/gateway/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/event/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/error/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
| apps/epics/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/delete-object/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/dcc/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/create-object/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/blinkt/main.c | Removes direct datalink header include; uses dlenv_init() + dlenv_cleanup() and routes periodic maintenance via bacnet_port_task_callback_set(dlenv_maintenance_timer). |
| apps/apdu/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/add-list-element/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/ack-alarm/main.c | Switches atexit() cleanup to dlenv_cleanup(). |
| apps/abort/main.c | Removes direct datalink header include; switches atexit() cleanup to dlenv_cleanup(). |
…v_cleanup function from dlenv.c and dlenv.h
… when no callback is set
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.