Page MenuHomeSoftware Heritage

statsd: protect access to the statsd's socket
ClosedPublic

Authored by douardda on Wed, Aug 28, 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

douardda created this revision.Wed, Aug 28, 10:40 AM
vlorentz added a subscriber: vlorentz.EditedWed, Aug 28, 10:45 AM

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.Mon, Sep 2, 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.Mon, Sep 2, 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...

douardda updated this revision to Diff 6598.Thu, Sep 5, 9:45 AM

update tests, as pointed out by olasd

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