cherry-pick some changes from chunking_callback to simplify the diff for review
cherry-pick some changes from chunking_callback to simplify the diff for review

open62541/open62541,bostjanv/open62541,jpfr/open62541,JGrothoff/open62541,jpfr/open62541,JGrothoff/open62541,AGIsmail/open62541,StalderT/open62541,StalderT/open62541,jpfr/open62541,JGrothoff/open62541,jpfr/open62541,open62541/open62541,StalderT/open62541,AGIsmail/open62541,bostjanv/open62541,StalderT/open62541,open62541/open62541,JGrothoff/open62541,open62541/open62541