@@ -313,13 +313,17 @@ namespace {
313
313
// connections that are still in the handshake
314
314
// will send their bitfield when the handshake
315
315
// is done
316
+ std::shared_ptr<torrent> t = associated_torrent ().lock ();
316
317
#ifndef TORRENT_DISABLE_EXTENSIONS
317
- write_upload_only ();
318
+ if (!t->share_mode ())
319
+ {
320
+ bool const upload_only_enabled = t->is_upload_only () && !t->super_seeding ();
321
+ send_upload_only (upload_only_enabled);
322
+ }
318
323
#endif
319
324
320
325
if (m_sent_bitfield) return ;
321
326
322
- std::shared_ptr<torrent> t = associated_torrent ().lock ();
323
327
TORRENT_ASSERT (t);
324
328
write_bitfield ();
325
329
TORRENT_ASSERT (m_sent_bitfield);
@@ -1902,42 +1906,36 @@ namespace {
1902
1906
return finished;
1903
1907
}
1904
1908
1905
- #ifndef TORRENT_DISABLE_EXTENSIONS
1906
- void bt_peer_connection::write_upload_only ()
1909
+ void bt_peer_connection::write_upload_only (bool const enabled)
1907
1910
{
1911
+ #ifndef TORRENT_DISABLE_EXTENSIONS
1908
1912
INVARIANT_CHECK;
1909
1913
1914
+ #if TORRENT_USE_ASSERTS
1910
1915
std::shared_ptr<torrent> t = associated_torrent ().lock ();
1916
+ TORRENT_ASSERT (!t->share_mode ());
1917
+ #endif
1918
+
1911
1919
if (m_upload_only_id == 0 ) return ;
1912
- if (t->share_mode ()) return ;
1913
1920
1914
1921
// if we send upload-only, the other end is very likely to disconnect
1915
1922
// us, at least if it's a seed. If we don't want to close redundant
1916
1923
// connections, don't sent upload-only
1917
1924
if (!m_settings.get_bool (settings_pack::close_redundant_connections)) return ;
1918
1925
1919
- #ifndef TORRENT_DISABLE_LOGGING
1920
- if (should_log (peer_log_alert::outgoing_message))
1921
- {
1922
- peer_log (peer_log_alert::outgoing_message, " UPLOAD_ONLY" , " %d"
1923
- , int (t->is_upload_only () && !t->super_seeding ()));
1924
- }
1925
- #endif
1926
-
1927
1926
char msg[7 ] = {0 , 0 , 0 , 3 , msg_extended};
1928
1927
char * ptr = msg + 5 ;
1929
1928
detail::write_uint8 (m_upload_only_id, ptr);
1930
- // if we're super seeding, we don't want to make peers
1931
- // think that we only have a single piece and is upload
1932
- // only, since they might disconnect immediately when
1933
- // they have downloaded a single piece, although we'll
1934
- // make another piece available
1935
- detail::write_uint8 (t->is_upload_only () && !t->super_seeding (), ptr);
1929
+ detail::write_uint8 (enabled, ptr);
1936
1930
send_buffer (msg);
1937
1931
1938
1932
stats_counters ().inc_stats_counter (counters::num_outgoing_extended);
1933
+ #else
1934
+ TORRENT_UNUSED (enabled);
1935
+ #endif
1939
1936
}
1940
1937
1938
+ #ifndef TORRENT_DISABLE_EXTENSIONS
1941
1939
void bt_peer_connection::write_share_mode ()
1942
1940
{
1943
1941
INVARIANT_CHECK;
0 commit comments