Picon
Favicon

Delete a torrent from within a torrent_plugin?

I'm writing a torrent_plugin.  In the plugin, when a certain condition 
is detected, I want to automatically delete the torrent with all of its 
files, including the fastresume.

How do I do so properly?

Everything
 I've tried so far either hasn't actually deleted the torrent, has lead 
to an invariant crash, or has caused a SEGV.  Here's a simplified view 
of the latest.  Any help would be appreciated!

struct foo : torrent_plugin {
  ...
  torrent* tp;
  ...
  virtual bool on_tick() {
    ...
    if (condition satisfied) {
      tp->set_error(errors::destructing_torrent, "...");
      tp->session().remove_torrent(tp->get_handle(),session::delete_files);
      return true;
    }
    ...
    return false;
  }
  ...
}
 
Spindizzy, the Dizzy Wizard
(spindizzy_wizard <at> yahoo.com)
(Continue reading)

Dmitry | 17 Jun 2012 10:03
Picon

Re: Delete a torrent from within a torrent_plugin?

Hi
There are some "standart" plugins in libtorrent. Maybe you try to
learn how theit works? And there are documentation about plugins on
libtorrent site.

2012/6/17 Spindizzy - The Dizzy Wizard <spindizzy_wizard <at> yahoo.com>:
> I'm writing a torrent_plugin.  In the plugin, when a certain condition
> is detected, I want to automatically delete the torrent with all of its
> files, including the fastresume.
>
> How do I do so properly?
>
> Everything
>  I've tried so far either hasn't actually deleted the torrent, has lead
> to an invariant crash, or has caused a SEGV.  Here's a simplified view
> of the latest.  Any help would be appreciated!
>
> struct foo : torrent_plugin {
>   ...
>   torrent* tp;
>   ...
>   virtual bool on_tick() {
>     ...
>     if (condition satisfied) {
>       tp->set_error(errors::destructing_torrent, "...");
>       tp->session().remove_torrent(tp->get_handle(),session::delete_files);
>       return true;
>     }
>     ...
>     return false;
(Continue reading)

Picon
Favicon

Re: Delete a torrent from within a torrent_plugin?

That's where I've been looking.  None of the existing plugins actually try to delete the torrent, and the
documentation assumes that you are deleting from 'outside' libtorrent, not from a plugin running within
the framework.

 
Spindizzy, the Dizzy Wizard
(spindizzy_wizard <at> yahoo.com)

________________________________
 From: Dmitry <russiankickingbear <at> gmail.com>
To: Spindizzy - The Dizzy Wizard <spindizzy_wizard <at> yahoo.com>; General discussion about libtorrent
<libtorrent-discuss <at> lists.sourceforge.net> 
Sent: Sunday, June 17, 2012 4:03 AM
Subject: Re: [libtorrent] Delete a torrent from within a torrent_plugin?

Hi
There are some "standart" plugins in libtorrent. Maybe you try to
learn how theit works? And there are documentation about plugins on
libtorrent site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
arvid | 17 Jun 2012 19:43
Picon
Picon
Favicon

Re: Delete a torrent from within a torrent_plugin?

Quoting Spindizzy - The Dizzy Wizard <spindizzy_wizard <at> yahoo.com>:

> That's where I've been looking.  None of the existing plugins actually try to
> delete the torrent, and the documentation assumes that you are deleting from
> 'outside' libtorrent, not from a plugin running within the framework.

The session and torrent_handle APIs send messages to the libtorrent thread,
which
then invokes functions on the aux::session_impl and torrent classes
respectively.

When invoking those functions from within the libtorrent thread, use the
functions on aux::session_impl and torrent directly.

The reason why the external functions don't work is because they send
a message to the libtorrent thread and then block, waiting for a response.
Since the libtorren thread is blocked in this case, it will never receive
the messages.

--

-- 
Arvid Norberg

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane