forked from premiere/premiere-libtorrent
Added utp-stats bjam option to enable utp stream log (utp.log file).
This commit is contained in:
parent
24b20a59cd
commit
02afc8b640
3
Jamfile
3
Jamfile
|
@ -472,6 +472,9 @@ feature.compose <invariant-checks>full : <define>TORRENT_EXPENSIVE_INVARIANT_CHE
|
||||||
feature disk-stats : off on : composite propagated link-incompatible ;
|
feature disk-stats : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
|
feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
|
||||||
|
|
||||||
|
feature utp-stats : off on : composite propagated link-incompatible ;
|
||||||
|
feature.compose <utp-stats>on : <define>TORRENT_UTP_LOG <define>TORRENT_VERBOSE_UTP_LOG ;
|
||||||
|
|
||||||
feature simulate-slow-read : off on : composite propagated ;
|
feature simulate-slow-read : off on : composite propagated ;
|
||||||
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
|
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
|
||||||
|
|
||||||
|
|
|
@ -468,6 +468,11 @@ public:
|
||||||
issue_write();
|
issue_write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TORRENT_UTP_LOG
|
||||||
|
static bool utp_stream_log();
|
||||||
|
static void utp_stream_log(bool enable);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// explicitly disallow assignment, to silence msvc warning
|
// explicitly disallow assignment, to silence msvc warning
|
||||||
utp_stream& operator=(utp_stream const&);
|
utp_stream& operator=(utp_stream const&);
|
||||||
|
|
|
@ -44,9 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#define TORRENT_UTP_LOG 0
|
|
||||||
#define TORRENT_VERBOSE_UTP_LOG 0
|
|
||||||
|
|
||||||
// the behavior of the sequence numbers as implemented by uTorrent is not
|
// the behavior of the sequence numbers as implemented by uTorrent is not
|
||||||
// particularly regular. This switch indicates the odd parts.
|
// particularly regular. This switch indicates the odd parts.
|
||||||
#define TORRENT_UT_SEQ 1
|
#define TORRENT_UT_SEQ 1
|
||||||
|
@ -70,7 +67,7 @@ static struct utp_logger
|
||||||
|
|
||||||
utp_logger() : utp_log_file(0)
|
utp_logger() : utp_log_file(0)
|
||||||
{
|
{
|
||||||
utp_log_file = fopen("utp.log", "w+");
|
utp_log_file = NULL;
|
||||||
}
|
}
|
||||||
~utp_logger()
|
~utp_logger()
|
||||||
{
|
{
|
||||||
|
@ -80,6 +77,8 @@ static struct utp_logger
|
||||||
|
|
||||||
void utp_log(char const* fmt, ...)
|
void utp_log(char const* fmt, ...)
|
||||||
{
|
{
|
||||||
|
if (log_file_holder.utp_log_file == NULL) return;
|
||||||
|
|
||||||
mutex::scoped_lock lock(log_file_holder.utp_log_mutex);
|
mutex::scoped_lock lock(log_file_holder.utp_log_mutex);
|
||||||
static time_point start = clock_type::now();
|
static time_point start = clock_type::now();
|
||||||
fprintf(log_file_holder.utp_log_file, "[%012" PRId64 "] ", total_microseconds(clock_type::now() - start));
|
fprintf(log_file_holder.utp_log_file, "[%012" PRId64 "] ", total_microseconds(clock_type::now() - start));
|
||||||
|
@ -1172,6 +1171,31 @@ void utp_stream::do_connect(tcp::endpoint const& ep)
|
||||||
m_impl->send_syn();
|
m_impl->send_syn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TORRENT_UTP_LOG
|
||||||
|
bool utp_stream::utp_stream_log() {
|
||||||
|
return log_file_holder.utp_log_file != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void utp_stream::utp_stream_log(bool enable) {
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if (log_file_holder.utp_log_file == NULL)
|
||||||
|
{
|
||||||
|
log_file_holder.utp_log_file = fopen("utp.log", "w+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (log_file_holder.utp_log_file != NULL)
|
||||||
|
{
|
||||||
|
FILE* f = log_file_holder.utp_log_file;
|
||||||
|
log_file_holder.utp_log_file = NULL;
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// =========== utp_socket_impl ============
|
// =========== utp_socket_impl ============
|
||||||
|
|
||||||
utp_socket_impl::~utp_socket_impl()
|
utp_socket_impl::~utp_socket_impl()
|
||||||
|
|
Loading…
Reference in New Issue