]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Factor out notify_init
authorVolker Lendecke <vl@samba.org>
Thu, 23 Jun 2016 10:53:47 +0000 (12:53 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 20 Jul 2016 03:21:06 +0000 (05:21 +0200)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/service.c

index 46bb226ecdfbd2addb6cec2b9d26d025f548f4d3..37440e01d5d4e7d90c25e8474f177eff21374c80 100644 (file)
@@ -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;
                }
        }