Page MenuHomeSoftware Heritage

statsd: protect access to the statsd's socket
ClosedPublic

Authored by douardda on Aug 28 2019, 10:40 AM.

Details

Summary

to prevent erratic errors when using heavily multithreaded code.

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Why isn't the socket initialized by __init__?

Why isn't the socket initialized by __init__?

we could, but it adds an extra line with no obvious improvement.

Why isn't the socket initialized by __init__?

And it was written like this before this refactoring (creation of the socket on demand), so I kept it as is.

olasd requested changes to this revision.Sep 2 2019, 4:32 PM
olasd added a subscriber: olasd.

You'll need to update the tests to set _socket instead.

This revision now requires changes to proceed.Sep 2 2019, 4:32 PM

with no obvious improvement.

It removes the need for a lock and a property.

with no obvious improvement.

It removes the need for a lock and a property.

Nope, one thread could call close_socket while another one is still doing stuff...

update tests, as pointed out by olasd

This revision is now accepted and ready to land.Sep 6 2019, 11:15 AM
This revision was automatically updated to reflect the committed changes.