Re: [PATCH samba v3 1/1] smbclient: cancel pending notify on SIGINT

ChenXiaoSong <[email protected]>
Newsgroups org.kernel.vger.linux-cifs
Message-ID <[email protected]>
在 2026/8/6 16:04, Ralph Böhme (@slowfranklin) 写道:
> 
> Ralph Böhme commented: https://gitlab.com/samba-team/samba/-/merge_requests/4530#note_3651484334
> 
> 
> Thanks! Generally looks good. Nitpick from README.Coding, in Samba we always enclose code after a conditional within braces, so you have to enclose the single line code after eg if conditions in braces please. Thanks! This is to ensure a future developer who adds additional code to the code at that place and forgets to then add the braces, doesn't break the logic.


Thanks for your review. I have updated the MR.

I made the following changes:

```
diff --git a/source3/client/client.c b/source3/client/client.c
index be41360dbdc..e12524ddf2e 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4669,8 +4669,9 @@ notify_sig_int_handler(
  {
         struct notify_state *state = (struct notify_state *)private_data;

-       if (state->notify_req)
+       if (state->notify_req) {
                 state->cancelled = tevent_req_cancel(state->notify_req);
+       }
  }

  static int cmd_notify(TALLOC_CTX *mem_ctx)
@@ -4692,6 +4693,7 @@ static int cmd_notify(TALLOC_CTX *mem_ctx)
                 goto fail;
         }
         if (!next_token_talloc(talloc_tos(), &cmd_ptr, &buf, NULL)) {
+               d_printf("notify <dir name>\n");
                 goto fail;
         }
         name = talloc_asprintf_append(name, "%s", buf);
@@ -4712,12 +4714,14 @@ static int cmd_notify(TALLOC_CTX *mem_ctx)
         }

         ev = samba_tevent_context_init(frame);
-       if (!ev)
+       if (!ev) {
                 goto close;
+       }

         se = tevent_add_signal(ev, frame, SIGINT, 0, 
notify_sig_int_handler, &sig_state);
-       if (!se)
+       if (!se) {
                 goto close;
+       }

         while (1) {
                 uint32_t i;
@@ -4730,14 +4734,22 @@ static int cmd_notify(TALLOC_CTX *mem_ctx)
                 }

                 req = cli_notify_send(frame, ev, cli, fnum, 1000, 
FILE_NOTIFY_CHANGE_ALL, true);
-               if (!req)
+               if (!req) {
                         goto close;
+               }
                 sig_state.notify_req = req;

-               if (!tevent_req_poll_ntstatus(req, ev, &status))
+               if (!tevent_req_poll_ntstatus(req, ev, &status)) {
                         goto close;
+               }

                 status = cli_notify_recv(req, talloc_tos(), 
&num_changes, &changes);
+               sig_state.notify_req = NULL;
+               TALLOC_FREE(req);
+               if (sig_state.cancelled) {
+                       printf("notify cancelled\n");
+                       goto close;
+               }
                 if (NT_STATUS_EQUAL(status, NT_STATUS_NOTIFY_ENUM_DIR)) {
                         printf("NOTIFY_ENUM_DIR\n");
                         status = NT_STATUS_OK;
```

-- 
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.