Merge pull request #105 from aldenml/torrent-alert-constructor
Recoded torrent_alert constructor logic to build the name.
This commit is contained in:
@@ -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("");
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user