Merge pull request #105 from aldenml/torrent-alert-constructor

Recoded torrent_alert constructor logic to build the name.
This commit is contained in:
Arvid Norberg 2015-08-20 21:36:30 +02:00
commit ef47b5f33f
2 changed files with 14 additions and 11 deletions

View File

@ -60,17 +60,20 @@ namespace libtorrent {
: handle(h) : handle(h)
, m_alloc(alloc) , m_alloc(alloc)
{ {
std::string name_str; boost::shared_ptr<torrent> t = h.native_handle();
if (h.native_handle()) if (t)
{ {
m_name_idx = alloc.copy_string(h.native_handle()->name()); std::string name_str = t->name();
if (!name_str.empty()) {
m_name_idx = alloc.copy_string(name_str);
} }
else if (h.is_valid()) else
{ {
char msg[41]; char msg[41];
to_hex(h.native_handle()->info_hash().data(), 20, msg); to_hex(t->info_hash().data(), 20, msg);
m_name_idx = alloc.copy_string(msg); m_name_idx = alloc.copy_string(msg);
} }
}
else else
{ {
m_name_idx = alloc.copy_string(""); m_name_idx = alloc.copy_string("");

View File

@ -74,7 +74,7 @@ namespace libtorrent
{ {
TORRENT_ASSERT(l.locked()); TORRENT_ASSERT(l.locked());
// wow, this is quite a hack // wow, this is quite a hack
pthread_cond_wait(&m_cond, reinterpret_cast<::pthread_mutex_t*>(&l.mutex())); pthread_cond_wait(&m_cond, reinterpret_cast<pthread_mutex_t*>(&l.mutex()));
} }
void condition_variable::wait_for(mutex::scoped_lock& l, time_duration rel_time) void condition_variable::wait_for(mutex::scoped_lock& l, time_duration rel_time)
@ -89,7 +89,7 @@ namespace libtorrent
ts.tv_sec = tv.tv_sec + total_seconds(rel_time) + microseconds / 1000000; ts.tv_sec = tv.tv_sec + total_seconds(rel_time) + microseconds / 1000000;
// wow, this is quite a hack // wow, this is quite a hack
pthread_cond_timedwait(&m_cond, reinterpret_cast<::pthread_mutex_t*>(&l.mutex()), &ts); pthread_cond_timedwait(&m_cond, reinterpret_cast<pthread_mutex_t*>(&l.mutex()), &ts);
} }
void condition_variable::notify_all() void condition_variable::notify_all()