Make an EADDRINUSE on server bind fatal.
This is important because if we try to rebind after a migration and someone else is in the way, any clients trying to reconnect to us will instead be connecting to the squatter.
This commit is contained in:
10
src/serve.c
10
src/serve.c
@@ -232,13 +232,21 @@ void serve_bind( struct server * serve )
|
|||||||
* Any of these other than EACCES,
|
* Any of these other than EACCES,
|
||||||
* EADDRINUSE or EADDRNOTAVAIL signify
|
* EADDRINUSE or EADDRNOTAVAIL signify
|
||||||
* that there's a logic error somewhere.
|
* that there's a logic error somewhere.
|
||||||
|
*
|
||||||
|
* EADDRINUSE is fatal: if there's
|
||||||
|
* something already where we want to be
|
||||||
|
* listening, we have no guarantees that
|
||||||
|
* any clients will cope with it.
|
||||||
*/
|
*/
|
||||||
case EACCES:
|
case EACCES:
|
||||||
case EADDRINUSE:
|
|
||||||
case EADDRNOTAVAIL:
|
case EADDRNOTAVAIL:
|
||||||
debug("retrying");
|
debug("retrying");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
|
case EADDRINUSE:
|
||||||
|
fatal( "%s port %d in use, giving up.",
|
||||||
|
s_address,
|
||||||
|
ntohs(serve->bind_to.v4.sin_port));
|
||||||
default:
|
default:
|
||||||
fatal( "Giving up" );
|
fatal( "Giving up" );
|
||||||
}
|
}
|
||||||
|
@@ -17,13 +17,5 @@ client.send_mirror()
|
|||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
squatter.close()
|
|
||||||
|
|
||||||
sleep(1)
|
|
||||||
|
|
||||||
client2 = FakeSource.new( newaddr, newport.to_i, "Timed out reconnecting" )
|
|
||||||
client2.read_hello
|
|
||||||
client2.read( 0, 8 )
|
|
||||||
client2.close
|
|
||||||
|
|
||||||
exit( 0 )
|
exit( 0 )
|
||||||
|
@@ -317,8 +317,13 @@ class FlexNBD
|
|||||||
_, status = Process.waitpid2( pid )
|
_, status = Process.waitpid2( pid )
|
||||||
|
|
||||||
if @kill
|
if @kill
|
||||||
fail "flexnbd quit with a bad status: #{status.exitstatus}" unless
|
if status.signaled?
|
||||||
@kill.include? status.exitstatus
|
fail "flexnbd quit with a bad signal: #{status.inspect}" unless
|
||||||
|
@kill.include? status.termsig
|
||||||
|
else
|
||||||
|
fail "flexnbd quit with a bad status: #{status.inspect}" unless
|
||||||
|
@kill.include? status.exitstatus
|
||||||
|
end
|
||||||
else
|
else
|
||||||
$stderr.puts "flexnbd #{self.pid} quit"
|
$stderr.puts "flexnbd #{self.pid} quit"
|
||||||
fail "flexnbd #{self.pid} quit early with status #{status.to_i}"
|
fail "flexnbd #{self.pid} quit early with status #{status.to_i}"
|
||||||
|
@@ -80,7 +80,8 @@ class TestDestErrorHandling < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_cant_rebind_retries
|
def test_cant_rebind_dies
|
||||||
|
@env.nbd1.can_die(6)
|
||||||
run_fake( "source/successful_transfer" )
|
run_fake( "source/successful_transfer" )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user