zephyr: Free received notices with ZFreeNotice.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c94da617ed
commit
7831d979c9
|
@ -228,6 +228,7 @@ def receive_zephyrs() -> None:
|
|||
logging.exception("Exception receiving zephyrs:")
|
||||
break
|
||||
if notice.z_opcode != b"":
|
||||
zephyr_ctypes.ZFreeNotice(byref(notice))
|
||||
continue
|
||||
notices.append(notice)
|
||||
|
||||
|
@ -335,6 +336,9 @@ z_contents = [
|
|||
(h_key_counts, h_missing_z, h_missing_h, h_duplicates, h_success) = process_keys(h_contents)
|
||||
(z_key_counts, z_missing_z, z_missing_h, z_duplicates, z_success) = process_keys(z_contents)
|
||||
|
||||
for notice in notices:
|
||||
zephyr_ctypes.ZFreeNotice(byref(notice))
|
||||
|
||||
if z_success and h_success:
|
||||
logger.info("Success!")
|
||||
print_status_and_exit(0)
|
||||
|
|
|
@ -167,6 +167,7 @@ ZGetSubscriptions = CFUNCTYPE(Code_t, POINTER(ZSubscription_t), POINTER(c_int))(
|
|||
)
|
||||
ZOpenPort = CFUNCTYPE(Code_t, POINTER(c_ushort))(("ZOpenPort", libzephyr))
|
||||
ZFlushSubscriptions = CFUNCTYPE(Code_t)(("ZFlushSubscriptions", libzephyr))
|
||||
ZFreeNotice = CFUNCTYPE(Code_t, POINTER(ZNotice_t))(("ZFreeNotice", libzephyr))
|
||||
ZSubscribeTo = CFUNCTYPE(Code_t, POINTER(ZSubscription_t), c_int, c_uint)(
|
||||
("ZSubscribeTo", libzephyr)
|
||||
)
|
||||
|
|
|
@ -321,13 +321,15 @@ def process_loop(zulip_queue: "Queue[ZephyrDict]", log: Optional[IO[str]]) -> No
|
|||
notice = zephyr_ctypes.ZNotice_t()
|
||||
sender = zephyr_ctypes.sockaddr_in()
|
||||
zephyr_ctypes.check(zephyr_ctypes.ZReceiveNotice(byref(notice), byref(sender)))
|
||||
recieve_backoff.succeed()
|
||||
try:
|
||||
recieve_backoff.succeed()
|
||||
process_notice(notice, zulip_queue, log)
|
||||
process_backoff.succeed()
|
||||
except zephyr_ctypes.ZephyrError:
|
||||
logger.exception("Error relaying zephyr:")
|
||||
process_backoff.fail()
|
||||
finally:
|
||||
zephyr_ctypes.ZFreeNotice(byref(notice))
|
||||
except zephyr_ctypes.ZephyrError:
|
||||
logger.exception("Error checking for new zephyrs:")
|
||||
recieve_backoff.fail()
|
||||
|
|
Loading…
Reference in a new issue