[PATCH] Fix terminate connection behavior for asynchronous endpoint with PUSH notification flavors

Stefan (metze) Metzmacher metze at samba.org
Mon Mar 30 05:22:52 MDT 2015


Am 30.03.2015 um 11:27 schrieb Julien Kerihuel:
> Hi Metze,
> 
> On 30/03/15 08:05, Stefan (metze) Metzmacher wrote:
>> Can you explain how dcerpc_server_asyncemsmdb_unbind() is triggered,
>> I can't see it just looking at the capture.
>>
>> Thanks!
>> metze
> To trigger it, I am setting the state_flag during the bind operation on
> the asyncemsmdb endpoint:
> 
> NTSTATUS dcerpc_server_asyncemsmdb_init(void);
> NTSTATUS ndr_table_register(const struct ndr_interface_table *);
> 
> #define DCESRV_INTERFACE_ASYNCEMSMDB_UNBIND     dcerpc_server_asyncemsmdb_unbind
> static NTSTATUS dcerpc_server_asyncemsmdb_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
> {
>         OC_DEBUG(0, "DISCONNECTION FROM CLIENT\n");
>         return NT_STATUS_OK;
> }
> 
> #define DCESRV_INTERFACE_ASYNCEMSMDB_BIND       dcerpc_server_asyncemsmdb_bind
> static NTSTATUS dcerpc_server_asyncemsmdb_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
> {
> 	dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_SKIP_PENDING_CALL;
> 	return NT_STATUS_OK;
> }
> 
> 
> In the dcerpc call of the interface, I'm setting the async flag, use
> tevent_add_fd to listen on a custom socket for remote system
> notification and only trigger dcesrv_reply call in the callback when
> there is something to read:
> 
> static void EcDoAsyncWaitEx_handler(
> [...]
>         status = dcesrv_reply(p->dce_call);
> 	if (!NT_STATUS_IS_OK(status)) {
>                 OC_DEBUG(0, "EcDoAsyncWaitEx_handler: dcesrv_reply() failed - %s", nt_errstr(status));
>         }
> [...]
> }
> 
> static NTSTATUS dcesrv_EcDoAsyncWaitEx(
> 
> [...]
> 	/* Set the asynchronous dcerpc flag on the connection */
> 	dce_call->state_flags |= DCESRV_CALL_STATE_FLAG_ASYNC;
> 
> [...]
>         if (!p->fd_event) {
>                 p->fd_event = tevent_add_fd(dce_call->event_ctx,
>                                             dce_call->event_ctx,
>                                             p->fd,
>                                             TEVENT_FD_READ,
>                                             EcDoAsyncWaitEx_handler,
>                                             p);
>                 if (p->fd_event == NULL) {
>                         OC_DEBUG(0, "[asyncemsmdb] unable to subscribe for fd event in event loop");
>                         return NT_STATUS_OK;
>                 }
>         }
> [...]
> 	return NT_STATUS_OK;
> }
> 
> 
> Now, because I call dcesrv_reply() from the callback, it means that I
> have an outstanding pending call as long as I didn't receive a
> notification on this custom p->fd socket from a remote system.

Sure.

But how is dcerpc_server_asyncemsmdb_unbind() called, with the your changes?
I don't see it called from dcesrv_terminate_connection().

> What is implemented in Samba is correct in all cases with regards to
> pending calls except this one. In this case, and without this patch,
> this connection is going to be considered broken 100% of the time.
> What I want, it for this connection to behave normally upon
> disconnection from client (close Outlook) and not be considered as a
> broken connection.

Why if the client disconnect, the connection is broken, why should we
pretend
it's not?

metze

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150330/2a40febc/attachment.pgp>


More information about the samba-technical mailing list