It would be useful to add an error string pointer to struct tevent_req
Richard Sharpe
realrichardsharpe at gmail.com
Tue Apr 30 18:39:49 MDT 2013
On Tue, Apr 30, 2013 at 1:04 PM, Jeremy Allison <jra at samba.org> wrote:
> On Tue, Apr 30, 2013 at 12:44:47PM -0700, Richard Sharpe wrote:
>> On Tue, Apr 30, 2013 at 11:55 AM, Jeremy Allison <jra at samba.org> wrote:
>> > On Tue, Apr 30, 2013 at 11:33:25AM -0700, Richard Sharpe wrote:
>> >> Hi folks,
>> >>
>> >> Because it can be hard to figure out where, say EINVAL, is coming
>> >> from, it would be useful to have a pointer to an error string where we
>> >> can talloc up, in the error path, something that tells you the
>> >> function and line number an error is coming from.
>> >>
>> >> Then when you have several sets of tevents along the way, you get a
>> >> better idea of why an error has really occurred.
>> >
>> > Do you have a more formal proposal of how we'd do this ?
>> > We can always reference a talloc'ed string on an 'error'
>> > context - problem is when to set it (not all code paths
>> > do or would) vs. just adding a specific debug where you
>> > suspect it.
>>
>> I am trying to determine if EINVAL is coming from the writev in static
>> void tstream_bsd_writev_handler(void *private_data) or from here:
>>
>> if (to_write == 0) {
>> tevent_req_error(req, EINVAL);
>> goto post;
>> }
>>
>>
>> in tstream_writev_send.
>>
>> At this level, I am not sure we can use DEBUG and friends.
>
> Well tevent_req_error() is a wrapper for :
>
> bool _tevent_req_error(struct tevent_req *req,
> uint64_t error,
> const char *location)
>
> which already stores the location in
> req->internal.finish_location
So, it seems that I would need to modify:
static void tstream_writev_done(struct tevent_req *subreq)
{
struct tevent_req *req = tevent_req_callback_data(subreq,
struct tevent_req);
struct tstream_writev_state *state = tevent_req_data(req,
struct tstream_writev_state);
ssize_t ret;
int sys_errno;
ret = state->ops->writev_recv(subreq, &sys_errno);
if (ret == -1) {
tevent_req_error(req, sys_errno);
return;
}
state->ret = ret;
tevent_req_done(req);
}
to use _tevent_req_error(req, sys_errno, subreq->internal.finish_location)
and all above it to use that as well.
It would be nicer to have that bubble up by itself.
--
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)
More information about the samba-technical
mailing list