No smb_raw_search_next in smb_cliraw.h

Stef Bon stefbon at gmail.com
Thu Jul 17 04:29:41 MDT 2014


2014-07-17 12:10 GMT+02:00 Stefan (metze) Metzmacher <metze at samba.org>:

>>
>> it will block the calling thread until the notify request is canceled.
>
> If you're using that, you're using it in a sync fashion.

Yes that's clear. I want to use it in a async fashion.

>
> If you want to use it async there should be only one tevent_context
> with tevent_loop_wait().
>
> Note that this code is not thread-safe!.

Aha! Why? I'm digging in the code just to find out that! Why is it not
thread safe?

And maybe you can tell me more about the reason to use the
tevent_loop_wait in stead of teven_loop_once.
I think that it's possible to have more than one thread waiting for a
reply using tevent_loop_once while being thread safe, but that
requires setting clever locks.

> And code in source4/libcli/raw/ doesn't provide a stable api for
> external usage.
> This is historically and doesn't use the tevent_req infrastructure yet.
> In future we may be able to provide an external async api, but that
> requires a lot of work.

Aha. As mentioned earlier a special thread (or threads) (and
callbacks) is required I think to handle these kind of *real* async
io.

>
> Your example should look like this:
>
> struct smbcli_request *notify_req1;
> struct smbcli_request *notify_req2;
> ...
>
> notify_req1 = smb_raw_changenotify_send(tree1, ...);
> if (notify_req1 == NULL) {
>    ...
> }
> notify_req1->async.fn = notify1_done;
> notify_req1->async.private_date = ...
>
> ...
>
> notify_req2 = smb_raw_changenotify_send(tree2, ...);
> if (notify_req2 == NULL) {
>    ...
> }
> notify_req2->async.fn = notify2_done;
> notify_req2->async.private_date = ...
>
> ...
>
> ASSERT(tree1->session->transport->ev == tree2->session->transport->ev);
> tevent_loop_wait(tree->sesson->transport->ev);
>
> ...
>
> static void notify1_done(struct smbcli_request *req)
> {
>      ...
>
>      status = smb_raw_changenotify_recv(req, ...);
>
>      ....
> }
>
> static void notify2_done(struct smbcli_request *req)
> {
>      ...
>
>      status = smb_raw_changenotify_recv(req, ...);
>
>      ....
> }

I know how it looks like, but I would like to understand the smbcli
library. Is it already async or are extra locks in my fuse fs required
to protect? See above.

Stef


More information about the samba-technical mailing list