A tevent function to propagate error info up the stack

Richard Sharpe realrichardsharpe at gmail.com
Wed May 1 07:24:35 MDT 2013


On Wed, May 1, 2013 at 5:29 AM, Simo <idra at samba.org> wrote:
> On 05/01/2013 01:24 AM, Richard Sharpe wrote:
>> Hi folks,
>>
>> This is designed to allow us to propagate error locations up the stack
>> so that DEBUG messages can tell us where the error really came from.
>>
>> Does this seem like a reasonable approach?
> Not sure it is.
> It would require you to keep around the subreq, which is something we do
> not do in tevent_req style requests.
> Why don't you simply ask for the location string and carry it on yourself ?
> Maybe a pair of functions, one to get the location and one to set it
> explicitly instead of implicitly so you can simply chain up this function:
>
> bool tevent_req_get_error(struct tevent_req *req,
> enum tevent_req_state *state,
> uint64_t *error,
> char **location);
>
> with this new one, by passing the retrieved location on your local state.
> location would be allocated on req and needs to be stolen as the req you
> retrieve it from (the subreq) is going to be freed soon enough, and
> usually before you use location.
>
> #define tevent_req_error_loc(req, error, location) \
> _tevent_req_error(req, error, __location__)

I wasn't actually going to keep the subreq around, only use it to grab
the location pointer.

However, we are going to need a function to get the location so what
you suggest might be the simplest approach.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list