You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
Feature request- Adding in user data for access in callbacks #249
I find I have to use global variables to pass the header-complete, message-complete events etc. between the callback and the thread that is polling a socket for data. Can there be a void pointer in the parser struct that I can use to assign to my own structs so that I can use the callbacks to set particular values in my passed structure?
I could make my structure global and have the callbacks access the elements directly but that's not neat in a multi-threaded environment.
There's a specific use case that highlights this problem (passing thread local data between a thread and an asynchronous modelled object) - in fact it's the problem I was trying to work around and what lead me here. I hope to address this so others don't have the same problem, or worse, think "http-parser" doesn't play nice with threads, time to use a different library...
Activity
hissohathair commentedon Jun 5, 2015
Doesn't that already exists in the parser_data struct?
indutny commentedon Jun 5, 2015
Yeah, this is already present. Sorry!
lberezy commentedon Jun 28, 2015
Perhaps some more documentation is necessary on the usage of this as it definitely wasn't super clear from the read-me.
indutny commentedon Jun 28, 2015
@lberezy this is very usual for C libraries, but if you feel like you want it - I'm absolutely fine with reviewing a Pull Request ;)
lberezy commentedon Jun 28, 2015
Definitely, I'll put something together.
There's a specific use case that highlights this problem (passing thread local data between a thread and an asynchronous modelled object) - in fact it's the problem I was trying to work around and what lead me here. I hope to address this so others don't have the same problem, or worse, think "http-parser" doesn't play nice with threads, time to use a different library...
lberezy commentedon Jun 28, 2015
sent ;)
#256