[PATCH] Make source3/libsmb cli_notify_send cancellable

Jeremy Allison jra at samba.org
Mon Nov 19 21:21:20 UTC 2018


On Mon, Nov 19, 2018 at 03:05:30PM +0100, Volker Lendecke via samba-technical wrote:
> Hi!
> 
> Review appreciated!
> 
> Thanks, Volker

One comment inline below:

> From d3479c59b94ff70850efa8af2a25066e3273ade9 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Fri, 16 Nov 2018 21:11:57 +0100
> Subject: [PATCH 6/6] libsmb: Make cli_notify_send cancellable
> 
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  source3/libsmb/clifile.c | 32 ++++++++++++++++++++++++--------
>  1 file changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
> index 1964a155005..8de34ff2637 100644
> --- a/source3/libsmb/clifile.c
> +++ b/source3/libsmb/clifile.c
> @@ -5491,6 +5491,7 @@ NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname)
>  ****************************************************************************/
>  
>  struct cli_notify_state {
> +	struct tevent_req *subreq;
>  	uint8_t setup[8];
>  	uint32_t num_changes;
>  	struct notify_change *changes;
> @@ -5498,6 +5499,7 @@ struct cli_notify_state {
>  
>  static void cli_notify_done(struct tevent_req *subreq);
>  static void cli_notify_done_smb2(struct tevent_req *subreq);
> +static bool cli_notify_cancel(struct tevent_req *req);
>  
>  struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
>  				   struct tevent_context *ev,
> @@ -5505,7 +5507,7 @@ struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
>  				   uint32_t buffer_size,
>  				   uint32_t completion_filter, bool recursive)
>  {
> -	struct tevent_req *req, *subreq;
> +	struct tevent_req *req;
>  	struct cli_notify_state *state;
>  	unsigned old_timeout;
>  
> @@ -5515,7 +5517,7 @@ struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
>  	}
>  
>  	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
> -		subreq = cli_smb2_notify_send(

I think we need:

+	        /*
+		 * Notifies should not time out
+		 */
+		old_timeout = cli_set_timeout(cli, 0);

added here to match the SMB1 behavior.

> +		state->subreq = cli_smb2_notify_send(
>  			state,
>  			ev,
>  			cli,
> @@ -5523,11 +5525,12 @@ struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
>  			buffer_size,
>  			completion_filter,
>  			recursive);

and this here to restore:

+		cli_set_timeout(cli, old_timeout);

> -		if (tevent_req_nomem(subreq, req)) {
> +		if (tevent_req_nomem(state->subreq, req)) {
>  			return tevent_req_post(req, ev);
>  		}
> -		tevent_req_set_callback(subreq, cli_notify_done_smb2, req);
> -		return req;
> +		tevent_req_set_callback(
> +			state->subreq, cli_notify_done_smb2, req);
> +		goto done;
>  	}

Do you agree ?

Attached is a squashable patch that add this into
the last patch in the set

If you're happy with that, RB+ by me.

Jeremy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SQUASHME-Ensure-cli_smb2_notify_send-doesn-t-time-ou.patch
Type: text/x-diff
Size: 1132 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20181119/61458b15/0001-SQUASHME-Ensure-cli_smb2_notify_send-doesn-t-time-ou.diff>


More information about the samba-technical mailing list