fix client_mutex lockup
This commit is contained in:
parent
8572479e9c
commit
5d38c21039
41
openwebrx.py
41
openwebrx.py
@ -224,6 +224,7 @@ class WebRXHandler(BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
global dsp_plugin
|
global dsp_plugin
|
||||||
|
global clients_mutex
|
||||||
rootdir = 'htdocs'
|
rootdir = 'htdocs'
|
||||||
self.path=self.path.replace("..","")
|
self.path=self.path.replace("..","")
|
||||||
path_temp_parts=self.path.split("?")
|
path_temp_parts=self.path.split("?")
|
||||||
@ -236,16 +237,17 @@ class WebRXHandler(BaseHTTPRequestHandler):
|
|||||||
if self.path[:4]=="/ws/":
|
if self.path[:4]=="/ws/":
|
||||||
try:
|
try:
|
||||||
# ========= WebSocket handshake =========
|
# ========= WebSocket handshake =========
|
||||||
|
ws_success=True
|
||||||
try:
|
try:
|
||||||
rxws.handshake(self)
|
rxws.handshake(self)
|
||||||
clients_mutex.acquire()
|
clients_mutex.acquire()
|
||||||
client_i=get_client_by_id(self.path[4:], False)
|
client_i=get_client_by_id(self.path[4:], False)
|
||||||
myclient=clients[client_i]
|
myclient=clients[client_i]
|
||||||
clients_mutex.release()
|
except rxws.WebSocketException: ws_success=False
|
||||||
except rxws.WebSocketException:
|
except ClientNotFoundException: ws_success=False
|
||||||
self.send_error(400, 'Bad request.')
|
finally:
|
||||||
return
|
if clients_mutex.locked(): clients_mutex.release()
|
||||||
except ClientNotFoundException:
|
if not ws_success:
|
||||||
self.send_error(400, 'Bad request.')
|
self.send_error(400, 'Bad request.')
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -310,25 +312,33 @@ class WebRXHandler(BaseHTTPRequestHandler):
|
|||||||
dsp.set_bpf(*new_bpf)
|
dsp.set_bpf(*new_bpf)
|
||||||
#code.interact(local=locals())
|
#code.interact(local=locals())
|
||||||
except:
|
except:
|
||||||
print "[openwebrx-httpd] exception happened at all"
|
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
if exc_value[0]==32: #"broken pipe", client disconnected
|
if exc_value[0]==32: #"broken pipe", client disconnected
|
||||||
pass
|
pass
|
||||||
elif exc_value[0]==11: #"resource unavailable" on recv, client disconnected
|
elif exc_value[0]==11: #"resource unavailable" on recv, client disconnected
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print "[openwebrx-httpd] error: ",exc_type,exc_value
|
print "[openwebrx-httpd] error in /ws/ handler: ",exc_type,exc_value
|
||||||
traceback.print_tb(exc_traceback)
|
traceback.print_tb(exc_traceback)
|
||||||
#delete disconnected client
|
|
||||||
|
#stop dsp for the disconnected client
|
||||||
try:
|
try:
|
||||||
dsp.stop()
|
dsp.stop()
|
||||||
del dsp
|
del dsp
|
||||||
except:
|
except:
|
||||||
pass
|
print "[openwebrx-httpd] error in dsp.stop()"
|
||||||
clients_mutex.acquire()
|
|
||||||
id_to_close=get_client_by_id(myclient.id,False)
|
#delete disconnected client
|
||||||
close_client(id_to_close,False)
|
try:
|
||||||
clients_mutex.release()
|
clients_mutex.acquire()
|
||||||
|
id_to_close=get_client_by_id(myclient.id,False)
|
||||||
|
close_client(id_to_close,False)
|
||||||
|
except:
|
||||||
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
|
print "[openwebrx-httpd] client cannot be closed: ",exc_type,exc_value
|
||||||
|
traceback.print_tb(exc_traceback)
|
||||||
|
finally:
|
||||||
|
clients_mutex.release()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
f=open(rootdir+self.path)
|
f=open(rootdir+self.path)
|
||||||
@ -375,8 +385,9 @@ class WebRXHandler(BaseHTTPRequestHandler):
|
|||||||
self.send_error(404, 'Invalid path.')
|
self.send_error(404, 'Invalid path.')
|
||||||
except:
|
except:
|
||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
print "[openwebrx-httpd] exception happened (outside):", exc_type, exc_value
|
print "[openwebrx-httpd] error (@outside):", exc_type, exc_value
|
||||||
traceback.print_tb(exc_traceback)
|
traceback.print_tb(exc_traceback)
|
||||||
|
|
||||||
|
|
||||||
class ClientNotFoundException(Exception):
|
class ClientNotFoundException(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -13,7 +13,7 @@ class dsp_plugin:
|
|||||||
self.offset_freq = 0
|
self.offset_freq = 0
|
||||||
self.low_cut = -4000
|
self.low_cut = -4000
|
||||||
self.high_cut = 4000
|
self.high_cut = 4000
|
||||||
self.bpf_transition_bw = 300 #Hz, and this is a constant
|
self.bpf_transition_bw = 320 #Hz, and this is a constant
|
||||||
self.ddc_transition_bw_rate = 0.15 # of the IF sample rate
|
self.ddc_transition_bw_rate = 0.15 # of the IF sample rate
|
||||||
self.running = False
|
self.running = False
|
||||||
chain_begin="nc localhost 4951 | csdr convert_u8_f | csdr shift_addition_cc --fifo {shift_pipe} | csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING | csdr bandpass_fir_fft_cc --fifo {bpf_pipe} {bpf_transition_bw} HAMMING | "
|
chain_begin="nc localhost 4951 | csdr convert_u8_f | csdr shift_addition_cc --fifo {shift_pipe} | csdr fir_decimate_cc {decimation} {ddc_transition_bw} HAMMING | csdr bandpass_fir_fft_cc --fifo {bpf_pipe} {bpf_transition_bw} HAMMING | "
|
||||||
|
Loading…
Reference in New Issue
Block a user