Skip to content

Commit

Permalink
Fix breakage in the ec42798.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed May 10, 2024
1 parent 0709547 commit 38dc916
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Rtp_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ class Broadcaster(object):
results = None
clim = None
cmd = None
orig_cmd = None

def __init__(self, bcount, clim, cmd):
def __init__(self, bcount, clim, cmd, orig_cmd):
self.results = []
self.bcount = bcount
self.ecount = bcount
self.nparts = bcount
self.clim = clim
self.cmd = cmd
self.orig_cmd = orig_cmd

class UdpCLIM(object):
cookie = None
Expand Down Expand Up @@ -167,7 +169,7 @@ def up_command(self, clim, orig_cmd):
response_handler = self.down_command
#print cmd
if len(self.active) == 0:
self.down_command('E999', clim, cmd, None)
self.down_command(clim, cmd, orig_cmd, None, 'E999')
return
if cmd.type in ('U', 'L', 'D', 'P', 'S', 'R', 'C', 'Q'):
#print(f'up_command: {cmd.call_id=}, {orig_cmd=}, {str(cmd)=}')
Expand Down Expand Up @@ -196,13 +198,13 @@ def up_command(self, clim, orig_cmd):
self.global_config['_sip_logger'].write('Delete request to a ' \
'(possibly) offline node "%s", sending fake reply and proceeding ' \
'in the background' % rtpp.name)
self.down_command('0', clim, cmd, None)
self.down_command(clim, cmd, orig_cmd, None, '0')
response_handler = self.ignore_response
if rtpp == None and new_session:
# New session
rtpp = self.pick_proxy(cmd.call_id)
if rtpp == None:
self.down_command('E998', clim, cmd, None)
self.down_command(clim, cmd, orig_cmd, None, 'E998')
return
rtpp.bind_session(cmd.call_id, cmd.type)
if rtpp != None and cmd.type in ('U', 'L') and cmd.ul_opts.notify_socket != None:
Expand All @@ -224,7 +226,7 @@ def up_command(self, clim, orig_cmd):
# Do a forced lookup
orig_cmd = 'L%s' % cmd.ul_opts.getstr(cmd.call_id, swaptags = True, skipnotify = True)
active = [x for x in self.active if x.online]
br = Broadcaster(len(active), clim, cmd)
br = Broadcaster(len(active), clim, cmd, orig_cmd)
for rtpp in active:
if cmd.type in ('U', 'L') and rtpp.lan_address != None:
out_cmd = Rtp_proxy_cmd(orig_cmd)
Expand All @@ -250,11 +252,11 @@ def up_command(self, clim, orig_cmd):
ptransmitted += rtpp.ptransmitted
reply = 'sessions created: %d\nactive sessions: %d\nactive streams: %d\npackets received: %d\npackets transmitted: %d' % \
(sessions_created, active_sessions, active_streams, preceived, ptransmitted)
self.down_command(reply, clim, cmd, None)
self.down_command(clim, cmd, orig_cmd, None, reply)
return
elif cmd.type == 'G':
active = [x for x in self.active if x.online]
br = Broadcaster(len(active), clim, cmd)
br = Broadcaster(len(active), clim, cmd, orig_cmd)
br.sobj = Rtpp_stats(cmd.args.split())
if cmd.command_opts != None and cmd.command_opts.lower() == 'v':
cmd.command_opts = None
Expand Down Expand Up @@ -320,14 +322,14 @@ def merge_results(self, result, br, rtpp):
return
if len(br.results) == 1:
rtpp.bind_session(br.cmd.call_id, br.cmd.type)
self.down_command(br.results[0], br.clim, br.cmd, rtpp)
self.down_command(br.clim, br.cmd, br.orig_cmd, rtpp, br.results[0])
else:
# No results or more than one proxy returns positive
# XXX: more than one result can probably be handled
if br.cmd.type in ('U', 'L'):
self.down_command('0', br.clim, br.cmd, rtpp)
self.down_command(br.clim, br.cmd, br.orig_cmd, rtpp, '0')
else:
self.down_command('E995', br.clim, br.cmd, rtpp)
self.down_command(br.clim, br.cmd, br.orig_cmd, rtpp, 'E995')

def merge_stats_results(self, result, br, rtpp):
#print 'merge_stats_results, result', result
Expand All @@ -352,7 +354,7 @@ def merge_stats_results(self, result, br, rtpp):
rval = 'E993'
else:
rval = str(br.sobj)
self.down_command(rval, br.clim, br.cmd, rtpp)
self.down_command(br.clim, br.cmd, br.orig_cmd, rtpp, rval)

def pick_proxy(self, call_id):
active = [(rtpp, rtpp.weight * (1 - rtpp.get_caputil())) \
Expand Down

0 comments on commit 38dc916

Please sign in to comment.