From 5a693303449db7f2d16a2ed16fef9dc42a894ba0 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 6 Feb 2010 14:43:28 +0000 Subject: [PATCH] (trunk libT) when we can't bind to a port and the error is EADDRINUSE, add a parenthetical hint "(Is another copy of Transmission already running?)" --- libtransmission/net.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libtransmission/net.c b/libtransmission/net.c index 1a0652d54..678c6220f 100644 --- a/libtransmission/net.c +++ b/libtransmission/net.c @@ -352,8 +352,22 @@ tr_netBindTCPImpl( const tr_address * addr, tr_port port, tr_bool suppressMsgs, if( bind( fd, (struct sockaddr *) &sock, addrlen ) ) { const int err = sockerrno; if( !suppressMsgs ) - tr_err( _( "Couldn't bind port %d on %s: %s" ), - port, tr_ntop_non_ts( addr ), tr_strerror( err ) ); + { + const char * fmt; + const char * hint; + + if( err == EADDRINUSE ) + hint = _( "Is another copy of Transmission already running?" ); + else + hint = NULL; + + if( hint == NULL ) + fmt = _( "Couldn't bind port %d on %s: %s" ); + else + fmt = _( "Couldn't bind port %d on %s: %s (%s)" ); + + tr_err( fmt, port, tr_ntop_non_ts( addr ), tr_strerror( err ), hint ); + } tr_netCloseSocket( fd ); *errOut = err; return -1;