1
0
mirror of https://github.com/samba-team/samba.git synced 2025-06-18 19:17:08 +03:00

s3:smbd: simplify the notify code a bit and always reply via change_notify_reply() -> send_nt_replies()

metze
This commit is contained in:
Stefan Metzmacher 2009-06-29 22:17:17 +02:00
parent 8b94eb6cc8
commit ef96e8c958
3 changed files with 30 additions and 35 deletions

View File

@ -6466,7 +6466,9 @@ void reply_negprot(struct smb_request *req);
/* The following definitions come from smbd/notify.c */ /* The following definitions come from smbd/notify.c */
void change_notify_reply(connection_struct *conn, void change_notify_reply(connection_struct *conn,
struct smb_request *req, uint32 max_param, struct smb_request *req,
NTSTATUS status,
uint32_t max_param,
struct notify_change_buf *notify_buf); struct notify_change_buf *notify_buf);
NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter, NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
bool recursive); bool recursive);

View File

@ -64,6 +64,10 @@ static bool notify_marshall_changes(int num_changes,
int i; int i;
UNISTR uni_name; UNISTR uni_name;
if (num_changes == -1) {
return false;
}
uni_name.buffer = NULL; uni_name.buffer = NULL;
for (i=0; i<num_changes; i++) { for (i=0; i<num_changes; i++) {
@ -131,37 +135,23 @@ static bool notify_marshall_changes(int num_changes,
Setup the common parts of the return packet and send it. Setup the common parts of the return packet and send it.
*****************************************************************************/ *****************************************************************************/
static void change_notify_reply_packet(connection_struct *conn,
struct smb_request *req,
NTSTATUS error_code)
{
reply_outbuf(req, 18, 0);
if (!NT_STATUS_IS_OK(error_code)) {
error_packet_set((char *)req->outbuf, 0, 0, error_code,
__LINE__,__FILE__);
}
show_msg((char *)req->outbuf);
if (!srv_send_smb(smbd_server_fd(),
(char *)req->outbuf,
true, req->seqnum+1,
req->encrypted, &req->pcd)) {
exit_server_cleanly("change_notify_reply_packet: srv_send_smb "
"failed.");
}
TALLOC_FREE(req->outbuf);
}
void change_notify_reply(connection_struct *conn, void change_notify_reply(connection_struct *conn,
struct smb_request *req, uint32 max_param, struct smb_request *req,
NTSTATUS error_code,
uint32_t max_param,
struct notify_change_buf *notify_buf) struct notify_change_buf *notify_buf)
{ {
prs_struct ps; prs_struct ps;
if (notify_buf->num_changes == -1) { if (!NT_STATUS_IS_OK(error_code)) {
change_notify_reply_packet(conn, req, NT_STATUS_OK); send_nt_replies(conn, req, error_code,
notify_buf->num_changes = 0; NULL, 0, NULL, 0);
return;
}
if (max_param == 0 || notify_buf == NULL) {
send_nt_replies(conn, req, NT_STATUS_OK,
NULL, 0, NULL, 0);
return; return;
} }
@ -173,14 +163,13 @@ void change_notify_reply(connection_struct *conn,
* We exceed what the client is willing to accept. Send * We exceed what the client is willing to accept. Send
* nothing. * nothing.
*/ */
change_notify_reply_packet(conn, req, NT_STATUS_OK); prs_mem_free(&ps);
goto done; prs_init_empty(&ps, NULL, MARSHALL);
} }
send_nt_replies(conn, req, NT_STATUS_OK, prs_data_p(&ps), send_nt_replies(conn, req, NT_STATUS_OK, prs_data_p(&ps),
prs_offset(&ps), NULL, 0); prs_offset(&ps), NULL, 0);
done:
prs_mem_free(&ps); prs_mem_free(&ps);
TALLOC_FREE(notify_buf->changes); TALLOC_FREE(notify_buf->changes);
@ -315,8 +304,8 @@ void remove_pending_change_notify_requests_by_mid(uint16 mid)
return; return;
} }
change_notify_reply_packet(map->req->fsp->conn, map->req->req, change_notify_reply(map->req->fsp->conn, map->req->req,
NT_STATUS_CANCELLED); NT_STATUS_CANCELLED, 0, NULL);
change_notify_remove_request(map->req); change_notify_remove_request(map->req);
} }
@ -332,8 +321,8 @@ void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
} }
while (fsp->notify->requests != NULL) { while (fsp->notify->requests != NULL) {
change_notify_reply_packet( change_notify_reply(fsp->conn, fsp->notify->requests->req,
fsp->conn, fsp->notify->requests->req, status); status, 0, NULL);
change_notify_remove_request(fsp->notify->requests); change_notify_remove_request(fsp->notify->requests);
} }
} }
@ -405,6 +394,7 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name)
if (fsp->notify->requests != NULL) { if (fsp->notify->requests != NULL) {
change_notify_reply(fsp->conn, change_notify_reply(fsp->conn,
fsp->notify->requests->req, fsp->notify->requests->req,
NT_STATUS_OK,
fsp->notify->requests->max_param, fsp->notify->requests->max_param,
fsp->notify); fsp->notify);
change_notify_remove_request(fsp->notify->requests); change_notify_remove_request(fsp->notify->requests);
@ -464,6 +454,7 @@ static void notify_fsp(files_struct *fsp, uint32 action, const char *name)
change_notify_reply(fsp->conn, change_notify_reply(fsp->conn,
fsp->notify->requests->req, fsp->notify->requests->req,
NT_STATUS_OK,
fsp->notify->requests->max_param, fsp->notify->requests->max_param,
fsp->notify); fsp->notify);

View File

@ -1592,7 +1592,9 @@ static void call_nt_transact_notify_change(connection_struct *conn,
* here. * here.
*/ */
change_notify_reply(fsp->conn, req, max_param_count, change_notify_reply(fsp->conn, req,
NT_STATUS_OK,
max_param_count,
fsp->notify); fsp->notify);
/* /*