merged python binding fix from RC_0_16

This commit is contained in:
Arvid Norberg
2012-09-11 17:20:31 +00:00
parent 0ec16827ff
commit 49709d1e3f

View File

@@ -21,9 +21,9 @@ namespace
void listen_on(session& s, int min_, int max_, char const* interface, int flags) void listen_on(session& s, int min_, int max_, char const* interface, int flags)
{ {
allow_threading_guard guard; allow_threading_guard guard;
error_code ec; error_code ec;
s.listen_on(std::make_pair(min_, max_), ec, interface, flags); s.listen_on(std::make_pair(min_, max_), ec, interface, flags);
if (ec) throw libtorrent_exception(ec); if (ec) throw libtorrent_exception(ec);
} }
void outgoing_ports(session& s, int _min, int _max) void outgoing_ports(session& s, int _min, int _max)
@@ -101,9 +101,11 @@ namespace
dict session_get_settings(session const& ses) dict session_get_settings(session const& ses)
{ {
allow_threading_guard guard; session_settings sett;
{
session_settings sett = ses.settings(); allow_threading_guard guard;
sett = ses.settings();
}
dict sett_dict; dict sett_dict;
bencode_map_entry* map; bencode_map_entry* map;
int len; int len;
@@ -264,8 +266,6 @@ namespace
feed_handle add_feed(session& s, dict params) feed_handle add_feed(session& s, dict params)
{ {
allow_threading_guard guard;
feed_settings feed; feed_settings feed;
// this static here is a bit of a hack. It will // this static here is a bit of a hack. It will
// probably work for the most part // probably work for the most part
@@ -273,14 +273,17 @@ namespace
std::list<std::string> string_storage; std::list<std::string> string_storage;
dict_to_feed_settings(params, feed, resume_buf, string_storage); dict_to_feed_settings(params, feed, resume_buf, string_storage);
allow_threading_guard guard;
return s.add_feed(feed); return s.add_feed(feed);
} }
dict get_feed_status(feed_handle const& h) dict get_feed_status(feed_handle const& h)
{ {
allow_threading_guard guard; feed_status s;
{
feed_status s = h.get_feed_status(); allow_threading_guard guard;
s = h.get_feed_status();
}
dict ret; dict ret;
ret["url"] = s.url; ret["url"] = s.url;
ret["title"] = s.title; ret["title"] = s.title;
@@ -307,14 +310,12 @@ namespace
item["info_hash"] = i->info_hash.to_string(); item["info_hash"] = i->info_hash.to_string();
items.append(item); items.append(item);
} }
ret["items"] = items; ret["items"] = items;
return ret; return ret;
} }
void set_feed_settings(feed_handle& h, dict sett) void set_feed_settings(feed_handle& h, dict sett)
{ {
allow_threading_guard guard;
feed_settings feed; feed_settings feed;
static std::vector<char> resume_buf; static std::vector<char> resume_buf;
std::list<std::string> string_storage; std::list<std::string> string_storage;
@@ -324,16 +325,18 @@ namespace
dict get_feed_settings(feed_handle& h) dict get_feed_settings(feed_handle& h)
{ {
allow_threading_guard guard; feed_settings s;
{
feed_settings s = h.settings(); allow_threading_guard guard;
s = h.settings();
}
dict ret; dict ret;
ret["url"] = s.url; ret["url"] = s.url;
ret["auto_download"] = s.auto_download; ret["auto_download"] = s.auto_download;
ret["default_ttl"] = s.default_ttl; ret["default_ttl"] = s.default_ttl;
return ret; return ret;
} }
void start_natpmp(session& s) void start_natpmp(session& s)
{ {
allow_threading_guard guard; allow_threading_guard guard;
@@ -354,9 +357,12 @@ namespace
list get_torrents(session& s) list get_torrents(session& s)
{ {
allow_threading_guard guard;
list ret; list ret;
std::vector<torrent_handle> torrents = s.get_torrents(); std::vector<torrent_handle> torrents;
{
allow_threading_guard guard;
torrents = s.get_torrents();
}
for (std::vector<torrent_handle>::iterator i = torrents.begin(); i != torrents.end(); ++i) for (std::vector<torrent_handle>::iterator i = torrents.begin(); i != torrents.end(); ++i)
{ {