fix issue with changing enable_dht causing segfault
enabling and disabling DHT no longer requires a restart
This commit is contained in:
parent
7c5af812c5
commit
0072fe6c6f
28
src/core.py
28
src/core.py
|
@ -194,20 +194,18 @@ class Manager:
|
||||||
# Saved torrent core_states. We do not poll the core in a costly manner, necessarily
|
# Saved torrent core_states. We do not poll the core in a costly manner, necessarily
|
||||||
self.saved_core_torrent_file_infos = {} # unique_ID -> torrent_state
|
self.saved_core_torrent_file_infos = {} # unique_ID -> torrent_state
|
||||||
|
|
||||||
|
# Keeps track of DHT running state
|
||||||
|
self.dht_running = False
|
||||||
|
|
||||||
# Load the preferences
|
# Load the preferences
|
||||||
self.config = pref.Preferences(os.path.join(self.base_dir, PREFS_FILENAME))
|
self.config = pref.Preferences(os.path.join(self.base_dir, PREFS_FILENAME))
|
||||||
|
|
||||||
|
# Set the enable_dht PREF_FUNCTION
|
||||||
|
PREF_FUNCTIONS["enable_dht"] = self.set_DHT
|
||||||
|
|
||||||
# Apply preferences. Note that this is before any torrents are added
|
# Apply preferences. Note that this is before any torrents are added
|
||||||
self.apply_prefs()
|
self.apply_prefs()
|
||||||
|
|
||||||
# Apply DHT, if needed. Note that this is before any torrents are added
|
|
||||||
if self.get_pref('enable_dht'):
|
|
||||||
if not blank_slate:
|
|
||||||
deluge_core.start_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
|
||||||
else:
|
|
||||||
deluge_core.start_DHT("")
|
|
||||||
|
|
||||||
# Unpickle the state, or create a new one
|
# Unpickle the state, or create a new one
|
||||||
if not blank_slate:
|
if not blank_slate:
|
||||||
try:
|
try:
|
||||||
|
@ -247,9 +245,7 @@ class Manager:
|
||||||
self.save_fastresume_data()
|
self.save_fastresume_data()
|
||||||
|
|
||||||
# Stop DHT, if needed
|
# Stop DHT, if needed
|
||||||
if self.get_pref('enable_dht'):
|
self.set_DHT(False)
|
||||||
print "Stopping DHT..."
|
|
||||||
deluge_core.stop_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
|
||||||
|
|
||||||
# Shutdown torrent core
|
# Shutdown torrent core
|
||||||
print "Quitting the core..."
|
print "Quitting the core..."
|
||||||
|
@ -349,7 +345,7 @@ class Manager:
|
||||||
# Get additional data from our level
|
# Get additional data from our level
|
||||||
ret['is_listening'] = deluge_core.is_listening()
|
ret['is_listening'] = deluge_core.is_listening()
|
||||||
ret['port'] = deluge_core.listening_port()
|
ret['port'] = deluge_core.listening_port()
|
||||||
if self.get_pref('enable_dht'):
|
if self.dht_running == True:
|
||||||
ret['DHT_nodes'] = deluge_core.get_DHT_info()
|
ret['DHT_nodes'] = deluge_core.get_DHT_info()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -716,6 +712,16 @@ class Manager:
|
||||||
if PREF_FUNCTIONS[pref] is not None:
|
if PREF_FUNCTIONS[pref] is not None:
|
||||||
PREF_FUNCTIONS[pref](self.get_pref(pref))
|
PREF_FUNCTIONS[pref](self.get_pref(pref))
|
||||||
|
|
||||||
|
def set_DHT(self, start=False):
|
||||||
|
if start == True:
|
||||||
|
print "Starting DHT..."
|
||||||
|
deluge_core.start_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
||||||
|
self.dht_running = True
|
||||||
|
elif start == False and self.dht_running == True:
|
||||||
|
print "Stopping DHT..."
|
||||||
|
deluge_core.stop_DHT(os.path.join(self.base_dir, DHT_FILENAME))
|
||||||
|
self.dht_running = False
|
||||||
|
|
||||||
# Calculations
|
# Calculations
|
||||||
|
|
||||||
def calc_ratio(self, unique_ID, torrent_state):
|
def calc_ratio(self, unique_ID, torrent_state):
|
||||||
|
|
|
@ -525,7 +525,7 @@ class DelugeGTK:
|
||||||
else:
|
else:
|
||||||
self.preferences_dialog.show()
|
self.preferences_dialog.show()
|
||||||
self.apply_prefs()
|
self.apply_prefs()
|
||||||
self.config.save_to_file()
|
self.config.save()
|
||||||
|
|
||||||
def show_plugin_dialog(self, arg=None):
|
def show_plugin_dialog(self, arg=None):
|
||||||
self.plugin_dialog.show()
|
self.plugin_dialog.show()
|
||||||
|
|
Loading…
Reference in New Issue