upnp more logging and error recovery

This commit is contained in:
Arvid Norberg 2007-09-01 04:08:39 +00:00
parent c8088459a0
commit fd42f3232b
19 changed files with 60 additions and 25 deletions

16
Jamfile
View File

@ -83,7 +83,7 @@ rule linking ( properties * )
{
# for backtraces in assertion failures
# which only works on ELF targets with gcc
result += <cxxflags>-rdynamic <source>src/assert.cpp ;
result += <linkflags>-export-dynamic <cxxflags>-rdynamic ;
}
if <boost>source in $(properties)
@ -104,6 +104,15 @@ rule building ( properties * )
{
local result ;
if <toolset>gcc in $(properties)
&& <target-os>linux in $(properties)
&& <variant>debug in $(properties)
{
# for backtraces in assertion failures
# which only works on ELF targets with gcc
result += <source>src/assert.cpp ;
}
if <openssl>off in $(properties)
{
result += <source>src/sha1.cpp ;
@ -270,6 +279,11 @@ local usage-requirements =
# disable bogus deprecation warnings on msvc8
<toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
# msvc optimizations
<toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
<toolset>msvc,<variant>release:<linkflags>/OPT:REF
# disable warning C4503: decorated name length exceeded, name was truncated
<toolset>msvc:<cxxflags>/wd4503
;
project torrent ;

View File

@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <memory>
#include <queue>
#include <string>
#include <cassert>
#include <typeinfo>
#ifdef _MSC_VER
@ -56,6 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/time.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#ifndef TORRENT_MAX_ALERT_TYPES
#define TORRENT_MAX_ALERT_TYPES 15

View File

@ -33,15 +33,17 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_ASSERT_HPP_INCLUDED
#define TORRENT_ASSERT_HPP_INCLUDED
#include <cassert>
#ifndef NDEBUG
#if defined __linux__ && defined _GNUC
#if defined __linux__ && defined __GNUC__
#ifdef assert
#undef assert
#endif
void assert_fail(int line, char const* file);
void assert_fail(const char* expr, int line, char const* file, char const* function);
#define assert(x) if (!(x)) assert_fail(__LINE__, __FILE__)
#define assert(x) if (!(x)) assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
#endif

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_CONFIG_HPP_INCLUDED
#include <boost/config.hpp>
#include "libtorrent/assert.hpp"
#if defined(__GNUC__) && __GNUC__ >= 4

View File

@ -64,10 +64,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <list>
#include <string>
#include <stdexcept>
#include <cassert>
#include "libtorrent/size_type.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -33,11 +33,11 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_HASHER_HPP_INCLUDED
#define TORRENT_HASHER_HPP_INCLUDED
#include <cassert>
#include <boost/cstdint.hpp>
#include "libtorrent/peer_id.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "zlib.h"
#ifdef TORRENT_USE_OPENSSL

View File

@ -34,8 +34,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_INTRUSIVE_PTR_BASE
#include <boost/detail/atomic_count.hpp>
#include <cassert>
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -5,7 +5,7 @@
#ifndef TORRENT_INVARIANT_ACCESS_HPP_INCLUDED
#define TORRENT_INVARIANT_ACCESS_HPP_INCLUDED
#include <cassert>
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define NODE_HPP
#include <algorithm>
#include <cassert>
#include <map>
#include <set>
@ -45,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/io.hpp>
#include <libtorrent/session_settings.hpp>
#include <libtorrent/assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/optional.hpp>

View File

@ -33,10 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
#define NODE_ID_HPP
#include <algorithm>
#include <cassert>
#include <boost/cstdint.hpp>
#include "libtorrent/peer_id.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent { namespace dht
{

View File

@ -35,13 +35,12 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_PE_CRYPTO_HPP_INCLUDED
#define TORRENT_PE_CRYPTO_HPP_INCLUDED
#include <cassert>
#include <openssl/dh.h>
#include <openssl/engine.h>
#include <openssl/rc4.h>
#include "peer_id.hpp" // For sha1_hash
#include "libtorrent/peer_id.hpp" // For sha1_hash
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -35,12 +35,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <string>
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
#include <vector>
#include <bitset>
#include <cassert>
#include <utility>
#ifdef _MSC_VER
@ -52,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -32,9 +32,11 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef NDEBUG
#include <stdlib.h>
#include <stdio.h>
#include <execinfo.h>
void assert_fail(int line, char const* file)
void assert_fail(char const* expr, int line, char const* file, char const* function)
{
fprintf(stderr, "assertion failed. Please file a bugreport at "
@ -42,9 +44,11 @@ void assert_fail(int line, char const* file)
"Please include the following information:\n\n"
"file: '%s'\n"
"line: %d\n"
"stack:\n", file, line);
"function: %s\n"
"expression: %s\n"
"stack:\n", file, line, function, expr);
void* stacktrace[50];
void* stack[50];
int size = backtrace(stack, 50);
char** symbols = backtrace_symbols(stack, size);
@ -54,6 +58,7 @@ void assert_fail(int line, char const* file)
}
free(symbols);
exit(1);
}
#endif

View File

@ -31,9 +31,9 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/pch.hpp"
#include "libtorrent/assert.hpp"
#include <string>
#include <cassert>
#include <stdexcept>
#include <sstream>
#include <iomanip>

View File

@ -34,10 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
#include <iomanip>
#include <cassert>
#include <boost/bind.hpp>
#include "libtorrent/kademlia/node_id.hpp"
#include "libtorrent/assert.hpp"
using boost::bind;

View File

@ -32,13 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISABLE_ENCRYPTION
#include <cassert>
#include <algorithm>
#include <openssl/dh.h>
#include <openssl/engine.h>
#include "libtorrent/pe_crypto.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent {

View File

@ -51,6 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/policy.hpp"
#include "libtorrent/socket_type.hpp"
#include "libtorrent/assert.hpp"
using boost::bind;
using boost::shared_ptr;

View File

@ -323,7 +323,13 @@ try
#endif
{
using namespace libtorrent::detail;
if (e) return;
if (e)
{
#ifdef TORRENT_UPNP_LOGGING
m_log << time_now_string() << " *** on_reply aborted: " << e.message() << std::endl;
#endif
return;
}
// parse out the url for the device
@ -843,9 +849,16 @@ void upnp::on_upnp_map_response(asio::error_code const& e
{
#ifdef TORRENT_UPNP_LOGGING
m_log << time_now_string()
<< " <== error while adding portmap: " << p.message() << std::endl;
<< " <== error while adding portmap: " << p.status_code() << " " << p.message() << std::endl;
#endif
m_devices.erase(d);
for (int i = 0; i < num_mappings; ++i)
{
if (d.mapping[i].need_update)
{
map_port(d, i);
return;
}
}
return;
}