Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#2850 closed enhancement (implemented)

use of SO_REUSEADDR socket option, was: Error binding network socket: Address already in use

Reported by: Falo Owned by:
Priority: High Milestone: Tor: 0.2.2.x-final
Component: Core Tor/Tor Version: Tor: 0.2.2.23-alpha
Severity: Keywords: tor-relay
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Blutmagie and Tory exits frequently log the error
Apr 04 15:27:48.706 [warn] Error binding network socket: Address already in use

According to Roger's answer to my today's posting on tor-relays mailing list the SO_REUSEADDR socket option isn't used in all cases. It might be an idea to set this option in any case.

Roger's answer

Actually, we only use SO_REUSEADDR when binding listening sockets. The errors you're seeing are likely because you can't open a new socket for an outbound connection. And we don't use SO_REUSEADDR when creating outbound sockets: see connection_connect().

We also don't set SO_REUSEADDR on the new socket we make after receiving connections on a listening socket: see connection_handle_listener_read().

I don't know what behavior to expect, but I would not be surprised to learn that we should set it in both of these cases too. Worth experimenting.

--Roger

Child Tickets

Change History (10)

comment:1 Changed 8 years ago by arma

Milestone: Tor: 0.2.2.x-final
Priority: normalmajor

Scheduling for 0.2.2, because "blutmagie exits frequently because" is something we should deal with.

comment:2 Changed 8 years ago by nickm

Status: newneeds_review

See branch bug2850 in my public repo.

This one needs testing. I'm worried that it will break something, somewhere, for somebody. If so, we should make it controlled by a config option.

comment:3 Changed 8 years ago by arma

The patch looks ok. (There's a conflict when it applies to master, but not a very tricky one.)

I agree it should get some testing somewhere. Perhaps Falo wants to test it on blutmagie?

I'm now running it on moria1 as well.

comment:4 Changed 8 years ago by arma

moria1 seemed fine with it.

comment:5 Changed 8 years ago by arma

Original report for reference is here:
http://archives.seul.org/tor/relays/Apr-2011/msg00006.html

comment:6 Changed 8 years ago by nickm

So we have reports from arma and mikeperry saying that this patch doesn't break anything, and/or might in fact help. I'm inclined to merge it and see whether it does any good. Objections?

comment:7 Changed 8 years ago by arma

Works for me. (That's why they call it an alpha. :)

comment:8 Changed 8 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Okay, merging & closing.

comment:9 Changed 7 years ago by nickm

Keywords: tor-relay added

comment:10 Changed 7 years ago by nickm

Component: Tor RelayTor
Note: See TracTickets for help on using tickets.