-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[refactor] Switched httpserver.cpp to use RAII wrapped libevents. #9517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/httpserver.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the manual release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because eventBase/eventHTTP are global and need them intact. If I don't release they'd be deleted on function return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I guess it improves consistency, and the .release(), if you added a comment noting the above about the lifetime, might be clearer than what was there before?
This change seems pointless IMHO, maybe I'm missing something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right. Addressing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding purpose: the one thing this brings is that no matter how things end, the base and http objects will be properly cleaned up. I have no idea what kind of side-effects an initialized and forgotten event base or evhttp might have. Perhaps none whatsoever.
src/httpserver.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened to the error handling? (https://github.com/bitcoin/bitcoin/blob/master/src/support/events.h#L33)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of event_base, the wrapper does the error handling already.
c7d7ecf to
e23ecf7
Compare
src/httpserver.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
eventBase = base_ctr.release();
eventHTTP = http_ctr.release();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks much better. I didn't realize you could do that. Thanks!
e23ecf7 to
0aa740c
Compare
0aa740c to
fd369d2
Compare
|
Rebased. |
|
Fast review ACK |
…symbol linker errors.
eb4bcb9 to
1ae86ec
Compare
gmaxwell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK (mostly tested ACK, I'm not so useful for reviewing this stuff. :) )
|
utACK 1ae86ec |
…ibevents. 1ae86ec Changed event RAII helper functions to inline to deal with duplicate symbol linker errors. (Karl-Johan Alm) fd369d2 Switched httpserver.cpp to use RAII wrapped libevents. (Kalle Alm) Tree-SHA512: 877e431f211024d42a3b0800e860e02833398611433e8393f8d5d4970f47f4bd670b900443678c067fec110c087aaab7dc1981ccbf17f6057676fdbbda89aed9
…apped libevents. 1ae86ec Changed event RAII helper functions to inline to deal with duplicate symbol linker errors. (Karl-Johan Alm) fd369d2 Switched httpserver.cpp to use RAII wrapped libevents. (Kalle Alm) Tree-SHA512: 877e431f211024d42a3b0800e860e02833398611433e8393f8d5d4970f47f4bd670b900443678c067fec110c087aaab7dc1981ccbf17f6057676fdbbda89aed9
Continuation of #9387. I believe this concludes fixing the
// XXX RAIIplaces.