Is it really done when you call tevent_req_done?

Richard Sharpe realrichardsharpe at gmail.com
Sat Jan 24 08:39:16 MST 2015


Hi folks,

In my seemingly never ending quest to understand tevent, I noticed the
following in some random smb2 request processing routine, like
smbd_smb2_request_process_tcon:

....

        subreq = smbd_smb2_tree_connect_send(req,
                                             req->sconn->ev_ctx,
                                             req,
                                             in_path_string);
        if (subreq == NULL) {
                return smbd_smb2_request_error(req, NT_STATUS_NO_MEMORY);
        }
        tevent_req_set_callback(subreq, smbd_smb2_request_tcon_done, req);

        return smbd_smb2_request_pending_queue(req, subreq, 500);

So, we create a subrequest in smbd_smb2_tree_connect_send and if we
got one, we set a callback (smbd_smb2_request_tcon_done and then call
that routine that will queue it perhaps.

However, when we look at smbd_smb2_tree_connect_send we see:

...
        status = smbd_smb2_tree_connect(smb2req,
                                        state->in_path,
                                        &state->out_share_type,
                                        &state->out_share_flags,
                                        &state->out_capabilities,
                                        &state->out_maximal_access,
                                        &state->out_tree_id);
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, ev);
        }

        tevent_req_done(req);
        return tevent_req_post(req, ev);

Huh, is it done or what? Done means finito, no more to do, etc. But
seemingly the request has a second life because tevent_req_post is
going to stick it in the tevent queue and then when we get back to our
caller it is going to be given a callback ...

I am confused and starting to feel like Alice:

'When I use a word,' Humpty Dumpty said, in rather a scornful tone,
'it means just what I choose it to mean — neither more nor less.'

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


More information about the samba-technical mailing list