From: Volker Lendecke Date: Thu, 23 Jun 2016 10:53:47 +0000 (+0200) Subject: smbd: Factor out notify_init X-Git-Tag: tdb-1.3.10~329 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c7bfdc6445a82823f3876eafe22cd7ec8ae95a2;p=thirdparty%2Fsamba.git smbd: Factor out notify_init Before this patch, failure of notify_init was ignored. Also, no proper error handling of a messaging_register failure was done. Fix those, also adding some debug messages. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 46bb226ecdf..37440e01d5d 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -520,6 +520,32 @@ NTSTATUS set_conn_force_user_group(connection_struct *conn, int snum) return NT_STATUS_OK; } +static NTSTATUS notify_init_sconn(struct smbd_server_connection *sconn) +{ + NTSTATUS status; + + if (sconn->notify_ctx != NULL) { + return NT_STATUS_OK; + } + + sconn->notify_ctx = notify_init(sconn, sconn->msg_ctx, sconn->ev_ctx); + if (sconn->notify_ctx == NULL) { + return NT_STATUS_NO_MEMORY; + } + + status = messaging_register(sconn->msg_ctx, sconn, + MSG_SMB_NOTIFY_CANCEL_DELETED, + smbd_notify_cancel_deleted); + if (!NT_STATUS_IS_OK(status)) { + DBG_DEBUG("messaging_register failed: %s\n", + nt_errstr(status)); + TALLOC_FREE(sconn->notify_ctx); + return status; + } + + return NT_STATUS_OK; +} + /**************************************************************************** Make a connection, given the snum to connect to, and the vuser of the connecting user if appropriate. @@ -689,13 +715,10 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, if ((!conn->printer) && (!conn->ipc) && lp_change_notify()) { - if (sconn->notify_ctx == NULL) { - sconn->notify_ctx = notify_init( - sconn, sconn->msg_ctx, sconn->ev_ctx); - status = messaging_register( - sconn->msg_ctx, sconn, - MSG_SMB_NOTIFY_CANCEL_DELETED, - smbd_notify_cancel_deleted); + + status = notify_init_sconn(sconn); + if (!NT_STATUS_IS_OK(status)) { + goto err_root_exit; } }