diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2014-03-30 14:14:28 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2014-03-30 14:14:28 +0900 |
| commit | f0473dc34dfb4d36b92aee49a6373704582338b5 (patch) | |
| tree | d418859af86887138cc884bbc2da7cbedcb45da9 | |
| parent | 551adc5133a6ca897b0345cfddb726cf92255305 (diff) | |
Ignore error when setting DSCP value
Setting DSCP is additional feature and failure to enable it should not
abort download entirely. This change fixes the bug that windows build
does not perform bittorrent downloads.
| -rw-r--r-- | src/SocketCore.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/SocketCore.cc b/src/SocketCore.cc index f560d939..df761463 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -535,15 +535,23 @@ void SocketCore::setTcpNodelay(bool f) void SocketCore::applyIpDscp() { - int family = getAddressFamily(); - if(family == AF_INET) { - setSockOpt(IPPROTO_IP, IP_TOS, &ipDscp_, sizeof(ipDscp_)); + if(ipDscp_ == 0) { + return; } + + try { + int family = getAddressFamily(); + if(family == AF_INET) { + setSockOpt(IPPROTO_IP, IP_TOS, &ipDscp_, sizeof(ipDscp_)); + } #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) - else if(family == AF_INET6) { - setSockOpt(IPPROTO_IPV6, IPV6_TCLASS, &ipDscp_, sizeof(ipDscp_)); - } + else if(family == AF_INET6) { + setSockOpt(IPPROTO_IPV6, IPV6_TCLASS, &ipDscp_, sizeof(ipDscp_)); + } #endif + } catch(RecoverableException& e) { + A2_LOG_INFO_EX("Applying DSCP value failed", e); + } } void SocketCore::setNonBlockingMode() |
