mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-04 15:43:28 +00:00
fix lsd
This commit is contained in:
parent
8e22078402
commit
f5f7f04e1e
@ -115,6 +115,8 @@ private:
|
|||||||
, asio::error_code const& e);
|
, asio::error_code const& e);
|
||||||
void on_assign_bandwidth(asio::error_code const& e);
|
void on_assign_bandwidth(asio::error_code const& e);
|
||||||
|
|
||||||
|
void callback(asio::error_code const& e, char const* data = 0, int size = 0);
|
||||||
|
|
||||||
std::vector<char> m_recvbuffer;
|
std::vector<char> m_recvbuffer;
|
||||||
tcp::socket m_sock;
|
tcp::socket m_sock;
|
||||||
int m_read_pos;
|
int m_read_pos;
|
||||||
|
@ -91,6 +91,9 @@ namespace libtorrent
|
|||||||
int content_length() const { return m_content_length; }
|
int content_length() const { return m_content_length; }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
std::map<std::string, std::string> const& headers() const { return m_header; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_recv_pos;
|
int m_recv_pos;
|
||||||
int m_status_code;
|
int m_status_code;
|
||||||
|
@ -96,9 +96,7 @@ void http_connection::on_connect_timeout()
|
|||||||
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
||||||
m_connection_ticket = -1;
|
m_connection_ticket = -1;
|
||||||
|
|
||||||
if (m_bottled && m_called) return;
|
callback(asio::error::timed_out);
|
||||||
m_called = true;
|
|
||||||
m_handler(asio::error::timed_out, m_parser, 0, 0);
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,12 +110,10 @@ void http_connection::on_timeout(boost::weak_ptr<http_connection> p
|
|||||||
|
|
||||||
if (e == asio::error::operation_aborted) return;
|
if (e == asio::error::operation_aborted) return;
|
||||||
|
|
||||||
if (c->m_bottled && c->m_called) return;
|
|
||||||
|
|
||||||
if (c->m_last_receive + c->m_timeout < time_now())
|
if (c->m_last_receive + c->m_timeout < time_now())
|
||||||
{
|
{
|
||||||
c->m_called = true;
|
c->callback(asio::error::timed_out);
|
||||||
c->m_handler(asio::error::timed_out, c->m_parser, 0, 0);
|
c->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,9 +134,7 @@ void http_connection::close()
|
|||||||
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
if (m_connection_ticket > -1) m_cc.done(m_connection_ticket);
|
||||||
m_connection_ticket = -1;
|
m_connection_ticket = -1;
|
||||||
|
|
||||||
if (m_called) return;
|
m_handler.clear();
|
||||||
m_called = true;
|
|
||||||
m_handler(asio::error::operation_aborted, m_parser, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void http_connection::on_resolve(asio::error_code const& e
|
void http_connection::on_resolve(asio::error_code const& e
|
||||||
@ -148,10 +142,8 @@ void http_connection::on_resolve(asio::error_code const& e
|
|||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
callback(e);
|
||||||
close();
|
close();
|
||||||
if (m_bottled && m_called) return;
|
|
||||||
m_called = true;
|
|
||||||
m_handler(e, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TORRENT_ASSERT(i != tcp::resolver::iterator());
|
TORRENT_ASSERT(i != tcp::resolver::iterator());
|
||||||
@ -187,10 +179,17 @@ void http_connection::on_connect(asio::error_code const& e
|
|||||||
}
|
}
|
||||||
*/ else
|
*/ else
|
||||||
{
|
{
|
||||||
|
callback(e);
|
||||||
close();
|
close();
|
||||||
if (m_bottled && m_called) return;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void http_connection::callback(asio::error_code const& e, char const* data, int size)
|
||||||
|
{
|
||||||
|
if (!m_bottled || !m_called)
|
||||||
|
{
|
||||||
m_called = true;
|
m_called = true;
|
||||||
m_handler(e, m_parser, 0, 0);
|
if (m_handler) m_handler(e, m_parser, data, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,10 +197,8 @@ void http_connection::on_write(asio::error_code const& e)
|
|||||||
{
|
{
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
callback(e);
|
||||||
close();
|
close();
|
||||||
if (m_bottled && m_called) return;
|
|
||||||
m_called = true;
|
|
||||||
m_handler(e, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +233,6 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
|
|
||||||
if (e == asio::error::eof)
|
if (e == asio::error::eof)
|
||||||
{
|
{
|
||||||
close();
|
|
||||||
if (m_bottled && m_called) return;
|
|
||||||
m_called = true;
|
|
||||||
char const* data = 0;
|
char const* data = 0;
|
||||||
std::size_t size = 0;
|
std::size_t size = 0;
|
||||||
if (m_bottled && m_parser.header_finished())
|
if (m_bottled && m_parser.header_finished())
|
||||||
@ -246,16 +240,15 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
data = m_parser.get_body().begin;
|
data = m_parser.get_body().begin;
|
||||||
size = m_parser.get_body().left();
|
size = m_parser.get_body().left();
|
||||||
}
|
}
|
||||||
m_handler(e, m_parser, data, size);
|
callback(e, data, size);
|
||||||
|
close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
callback(e);
|
||||||
close();
|
close();
|
||||||
if (m_bottled && m_called) return;
|
|
||||||
m_called = true;
|
|
||||||
m_handler(e, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,9 +266,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
if (url.empty())
|
if (url.empty())
|
||||||
{
|
{
|
||||||
// missing location header
|
// missing location header
|
||||||
if (m_bottled && m_called) return;
|
callback(e);
|
||||||
m_called = true;
|
|
||||||
m_handler(e, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +288,7 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
if (!m_bottled && m_parser.header_finished())
|
if (!m_bottled && m_parser.header_finished())
|
||||||
{
|
{
|
||||||
if (m_read_pos > m_parser.body_start())
|
if (m_read_pos > m_parser.body_start())
|
||||||
m_handler(e, m_parser, &m_recvbuffer[0] + m_parser.body_start()
|
callback(e, &m_recvbuffer[0] + m_parser.body_start()
|
||||||
, m_read_pos - m_parser.body_start());
|
, m_read_pos - m_parser.body_start());
|
||||||
m_read_pos = 0;
|
m_read_pos = 0;
|
||||||
m_last_receive = time_now();
|
m_last_receive = time_now();
|
||||||
@ -305,15 +296,13 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
else if (m_bottled && m_parser.finished())
|
else if (m_bottled && m_parser.finished())
|
||||||
{
|
{
|
||||||
m_timer.cancel();
|
m_timer.cancel();
|
||||||
if (m_bottled && m_called) return;
|
callback(e, m_parser.get_body().begin, m_parser.get_body().left());
|
||||||
m_called = true;
|
|
||||||
m_handler(e, m_parser, m_parser.get_body().begin, m_parser.get_body().left());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(!m_bottled);
|
TORRENT_ASSERT(!m_bottled);
|
||||||
m_handler(e, m_parser, &m_recvbuffer[0], m_read_pos);
|
callback(e, &m_recvbuffer[0], m_read_pos);
|
||||||
m_read_pos = 0;
|
m_read_pos = 0;
|
||||||
m_last_receive = time_now();
|
m_last_receive = time_now();
|
||||||
}
|
}
|
||||||
@ -322,10 +311,8 @@ void http_connection::on_read(asio::error_code const& e
|
|||||||
m_recvbuffer.resize((std::min)(m_read_pos + 2048, int(max_bottled_buffer)));
|
m_recvbuffer.resize((std::min)(m_read_pos + 2048, int(max_bottled_buffer)));
|
||||||
if (m_read_pos == max_bottled_buffer)
|
if (m_read_pos == max_bottled_buffer)
|
||||||
{
|
{
|
||||||
|
callback(asio::error::eof);
|
||||||
close();
|
close();
|
||||||
if (m_bottled && m_called) return;
|
|
||||||
m_called = true;
|
|
||||||
m_handler(asio::error::eof, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int amount_to_read = m_recvbuffer.size() - m_read_pos;
|
int amount_to_read = m_recvbuffer.size() - m_read_pos;
|
||||||
@ -351,8 +338,7 @@ void http_connection::on_assign_bandwidth(asio::error_code const& e)
|
|||||||
&& m_limiter_timer_active)
|
&& m_limiter_timer_active)
|
||||||
|| !m_sock.is_open())
|
|| !m_sock.is_open())
|
||||||
{
|
{
|
||||||
if (!m_bottled || !m_called)
|
callback(asio::error::eof);
|
||||||
m_handler(e, m_parser, 0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_limiter_timer_active = false;
|
m_limiter_timer_active = false;
|
||||||
|
@ -185,5 +185,7 @@ void lsd::close()
|
|||||||
{
|
{
|
||||||
m_socket.close();
|
m_socket.close();
|
||||||
m_broadcast_timer.cancel();
|
m_broadcast_timer.cancel();
|
||||||
|
m_disabled = true;
|
||||||
|
m_callback.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1642,15 +1642,14 @@ static PyObject *torrent_use_lsd(PyObject *self, PyObject *args)
|
|||||||
python_long action;
|
python_long action;
|
||||||
PyArg_ParseTuple(args, "i", &action);
|
PyArg_ParseTuple(args, "i", &action);
|
||||||
|
|
||||||
/* if (action){
|
if (action){
|
||||||
M_ses->start_lsd();
|
M_ses->start_lsd();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
M_ses->stop_lsd();
|
M_ses->stop_lsd();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
Py_INCREF(Py_None); return Py_None;
|
|
||||||
|
|
||||||
|
Py_INCREF(Py_None); return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *torrent_use_natpmp(PyObject *self, PyObject *args)
|
static PyObject *torrent_use_natpmp(PyObject *self, PyObject *args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user