Re: [PATCH 14/16] move async_client_callback and async_client_context into remote_state

Tom Tromey
2013-06-24T18:43:51Z

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> static void
>> remote_async_serial_handler (struct serial *scb, void *context)
>> {
>> + struct remote_state *rs = context;

Pedro> Does this actually work?

>> + serial_async (rs->remote_desc, remote_async_serial_handler, rs);
>> + rs->async_client_callback = callback;
>> + rs->async_client_context = context;

Pedro> Because I think CONTEXT is always NULL here.

Pedro> And it'd seem a wrong to me to store the remote state in the
Pedro> meant for context passed in by the target_async's caller?

I think it should work.

There are two callbacks and two "context" values here.

In that second snippet, "callback" and "context" are the arguments to
remote_async. We stash those in the struct remote_state.

Then we call serial_async with remote_async_serial_handler as a callback
and with the remote_state as the context.

When remote_async_serial_handler is called, we fetch the original
callback and the original context from the remote_state, and call those.

We need this second callback layer because we want to add in the
INF_REG_EVENT argument.

I hope that's clear and correct.

Tom