HomeClusterLabs Projects

Refactor: libcrmcommon: Free the client buffer before reading a reply.

Description

Refactor: libcrmcommon: Free the client buffer before reading a reply.

This is a little bit complicated.

The mainloop_gio_callback function gets called when there's new data to
read out of an IO channel, for instance an IPC connection. This
function reads the data and then if there's a dispatch function, calls
it with the read data.

The dispatch function varies depending on server - it could be
remote_proxy_dispatch for remote nodes, or stonith_dispatch_internal for
the fencer, or various other functions. These dispatch functions in
turn can call all sorts of other things, including crm_ipc_send with the
expectation of then receiving a reply.

In order to read a reply, we need the client receive buffer empty or
else pcmk__ipc_msg_append will assert. One potential way around this is
to free the client buffer in mainloop_gio_callback before calling the
dispatch function.

Unfortunately, this won't work for remote nodes because
remote_proxy_dispatch is called with its userdata argument pointing at a
remote_proxy_t, which in turn includes a reference to the crm_ipc_t
object containing the buffer we would have just freed. It needs this to
examine the flags and decide whether to send its data as a reply or
event.

Because the dispatch functions call so many other functions, some of
which in turn call other callbacks that were registered somewhere, it
seems difficult and fragile to track down everywhere that crm_ipc_send
could be called and make sure we free the buffer. Instead, we can just
free it in crm_ipc_send before calling internal_ipc_get_reply. The
buffer won't contain anything we care about at that point since we are
just about to write new data to it anyway.

Details

Provenance
clumensAuthored on Tue, May 27, 1:00 PM
Parents
rPdcba14fcd5c5: Feature: libcrmcommon: crm_ipc_send can send large IPC messages.
Branches
Unknown
Tags
Unknown