mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
traffic: improve is_really_a_packet
This function will repeat on each packet. Avoid exception for getattr, which is expensive for performance. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
parent
c1af6a0dad
commit
38fc8125e2
@ -273,13 +273,12 @@ class Packet(object):
|
||||
return False
|
||||
|
||||
fn_name = 'packet_%s_%s' % (self.protocol, self.opcode)
|
||||
try:
|
||||
fn = getattr(traffic_packets, fn_name)
|
||||
if fn is traffic_packets.null_packet:
|
||||
return False
|
||||
except AttributeError:
|
||||
fn = getattr(traffic_packets, fn_name, None)
|
||||
if not fn:
|
||||
print("missing packet %s" % fn_name, file=sys.stderr)
|
||||
return False
|
||||
if fn is traffic_packets.null_packet:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user