Changeset View
Changeset View
Standalone View
Standalone View
ktorrent/core.cpp
Context not available. | |||||
174 | } | 174 | } | ||
---|---|---|---|---|---|
175 | } | 175 | } | ||
176 | 176 | | |||
177 | void Core::startUTPServer(bt::Uint16 port) | 177 | bool Core::startUTPServer(bt::Uint16 port) | ||
178 | { | 178 | { | ||
179 | if (Globals::instance().initUTPServer(port)) | 179 | if (Globals::instance().initUTPServer(port)) | ||
180 | { | 180 | { | ||
Context not available. | |||||
185 | gui->errorMsg(i18n("KTorrent is unable to accept connections because the UDP port %1 is " | 185 | gui->errorMsg(i18n("KTorrent is unable to accept connections because the UDP port %1 is " | ||
186 | "already in use by another program.", port)); | 186 | "already in use by another program.", port)); | ||
187 | Out(SYS_GEN | LOG_IMPORTANT) << "Cannot find free UDP port" << endl; | 187 | Out(SYS_GEN | LOG_IMPORTANT) << "Cannot find free UDP port" << endl; | ||
188 | return false; | ||||
188 | } | 189 | } | ||
190 | return true; | ||||
189 | } | 191 | } | ||
190 | 192 | | |||
191 | 193 | | |||
Context not available. | |||||
207 | else if (tcp_enabled && port != current_port) | 209 | else if (tcp_enabled && port != current_port) | ||
208 | globals.getTCPServer().changePort(port); | 210 | globals.getTCPServer().changePort(port); | ||
209 | 211 | | |||
210 | if (globals.isUTPEnabled() && !utp_enabled) | 212 | if (globals.isUTPEnabled() && (!utp_enabled || port != current_port) ) | ||
211 | globals.shutdownUTPServer(); | 213 | globals.shutdownUTPServer(); | ||
212 | else if (!globals.isUTPEnabled() && utp_enabled) | 214 | if (!globals.isUTPEnabled() && utp_enabled) | ||
213 | startUTPServer(port); | 215 | startUTPServer(port); | ||
214 | else if (utp_enabled && port != current_port) | | |||
215 | globals.getUTPServer().changePort(port); | | |||
216 | 216 | | |||
217 | if (utp_enabled) | 217 | if (utp_enabled) | ||
218 | globals.getUTPServer().setTOS(Settings::dscp() << 2); | 218 | globals.getUTPServer().setTOS(Settings::dscp() << 2); | ||
Context not available. | |||||
1103 | 1103 | | |||
1104 | bool Core::changePort(Uint16 port) | 1104 | bool Core::changePort(Uint16 port) | ||
1105 | { | 1105 | { | ||
1106 | bt::Globals& globals = bt::Globals::instance(); | ||||
1106 | bool ok = false; | 1107 | bool ok = false; | ||
1107 | if (Settings::utpEnabled()) | 1108 | if (Settings::utpEnabled()) | ||
1108 | { | 1109 | { | ||
1109 | utp::UTPServer& utp_srv = Globals::instance().getUTPServer(); | 1110 | globals.shutdownUTPServer(); | ||
1110 | ok = utp_srv.changePort(port); | 1111 | ok = startUTPServer(port); | ||
1112 | | ||||
1111 | if (!Settings::onlyUseUtp()) | 1113 | if (!Settings::onlyUseUtp()) | ||
1112 | { | 1114 | { | ||
1113 | bt::Server& srv = Globals::instance().getTCPServer(); | 1115 | bt::Server& srv = globals.getTCPServer(); | ||
1114 | ok = ok && srv.changePort(port); | 1116 | ok = ok && srv.changePort(port); | ||
1115 | } | 1117 | } | ||
1116 | } | 1118 | } | ||
1117 | else | 1119 | else | ||
1118 | { | 1120 | { | ||
1119 | bt::Server& srv = Globals::instance().getTCPServer(); | 1121 | bt::Server& srv = globals.getTCPServer(); | ||
1120 | ok = srv.changePort(port); | 1122 | ok = srv.changePort(port); | ||
1121 | } | 1123 | } | ||
1122 | 1124 | | |||
Context not available. |