From: Volker Lendecke Date: Tue, 6 Oct 2020 15:04:05 +0000 (+0200) Subject: notifyd: Modernize DBG statements X-Git-Tag: talloc-2.3.2~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c71d52b9f5e84fb0b5383c2d49aaf9244c95fd72;p=thirdparty%2Fsamba.git notifyd: Modernize DBG statements Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c index 6ff1de5b5fe..ba030fa1ecc 100644 --- a/source3/smbd/notifyd/notifyd.c +++ b/source3/smbd/notifyd/notifyd.c @@ -243,8 +243,8 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ret = server_id_db_set_exclusive(names_db, "notify-daemon"); if (ret != 0) { - DEBUG(10, ("%s: server_id_db_add failed: %s\n", - __func__, strerror(ret))); + DBG_DEBUG("server_id_db_add failed: %s\n", + strerror(ret)); tevent_req_error(req, ret); goto deregister_get_db; } @@ -351,8 +351,7 @@ static bool notifyd_parse_entry(uint8_t *buf, size_t buflen, size_t *num_instances) { if ((buflen % sizeof(struct notifyd_instance)) != 0) { - DEBUG(1, ("%s: invalid buffer size: %u\n", - __func__, (unsigned)buflen)); + DBG_WARNING("invalid buffer size: %zu\n", buflen); return false; } @@ -384,25 +383,27 @@ static bool notifyd_apply_rec_change( bool ok = false; if (pathlen == 0) { - DEBUG(1, ("%s: pathlen==0\n", __func__)); + DBG_WARNING("pathlen==0\n"); return false; } if (path[pathlen-1] != '\0') { - DEBUG(1, ("%s: path not 0-terminated\n", __func__)); + DBG_WARNING("path not 0-terminated\n"); return false; } - DEBUG(10, ("%s: path=%s, filter=%u, subdir_filter=%u, " - "private_data=%p\n", __func__, path, - (unsigned)chg->filter, (unsigned)chg->subdir_filter, - chg->private_data)); + DBG_DEBUG("path=%s, filter=%"PRIu32", subdir_filter=%"PRIu32", " + "private_data=%p\n", + path, + chg->filter, + chg->subdir_filter, + chg->private_data); rec = dbwrap_fetch_locked( entries, entries, make_tdb_data((const uint8_t *)path, pathlen-1)); if (rec == NULL) { - DEBUG(1, ("%s: dbwrap_fetch_locked failed\n", __func__)); + DBG_WARNING("dbwrap_fetch_locked failed\n"); goto fail; } @@ -422,7 +423,7 @@ static bool notifyd_apply_rec_change( instances = talloc_array(rec, struct notifyd_instance, num_instances + 1); if (instances == NULL) { - DEBUG(1, ("%s: talloc failed\n", __func__)); + DBG_WARNING("talloc failed\n"); goto fail; } @@ -482,14 +483,13 @@ static bool notifyd_apply_rec_change( num_instances -= 1; } - DEBUG(10, ("%s: %s has %u instances\n", __func__, - path, (unsigned)num_instances)); + DBG_DEBUG("%s has %zu instances\n", path, num_instances); if (num_instances == 0) { status = dbwrap_record_delete(rec); if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("%s: dbwrap_record_delete returned %s\n", - __func__, nt_errstr(status))); + DBG_WARNING("dbwrap_record_delete returned %s\n", + nt_errstr(status)); goto fail; } } else { @@ -499,8 +499,8 @@ static bool notifyd_apply_rec_change( status = dbwrap_record_store(rec, value, 0); if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("%s: dbwrap_record_store returned %s\n", - __func__, nt_errstr(status))); + DBG_WARNING("dbwrap_record_store returned %s\n", + nt_errstr(status)); goto fail; } } @@ -548,19 +548,20 @@ static bool notifyd_parse_rec_change(uint8_t *buf, size_t bufsize, struct notify_rec_change_msg *msg; if (bufsize < offsetof(struct notify_rec_change_msg, path) + 1) { - DEBUG(1, ("%s: message too short, ignoring: %u\n", __func__, - (unsigned)bufsize)); + DBG_WARNING("message too short, ignoring: %zu\n", bufsize); return false; } *pmsg = msg = (struct notify_rec_change_msg *)buf; *pathlen = bufsize - offsetof(struct notify_rec_change_msg, path); - DEBUG(10, ("%s: Got rec_change_msg filter=%u, subdir_filter=%u, " - "private_data=%p, path=%.*s\n", - __func__, (unsigned)msg->instance.filter, - (unsigned)msg->instance.subdir_filter, - msg->instance.private_data, (int)(*pathlen), msg->path)); + DBG_DEBUG("Got rec_change_msg filter=%"PRIu32", " + "subdir_filter=%"PRIu32", private_data=%p, path=%.*s\n", + msg->instance.filter, + msg->instance.subdir_filter, + msg->instance.private_data, + (int)(*pathlen), + msg->path); return true; } @@ -593,8 +594,7 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx, state->entries, state->sys_notify_watch, state->sys_notify_ctx, state->msg_ctx); if (!ok) { - DEBUG(1, ("%s: notifyd_apply_rec_change failed, ignoring\n", - __func__)); + DBG_DEBUG("notifyd_apply_rec_change failed, ignoring\n"); return; } @@ -614,7 +614,7 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx, tmp = talloc_realloc(log, log->recs, struct messaging_rec *, log->num_recs+1); if (tmp == NULL) { - DEBUG(1, ("%s: talloc_realloc failed, ignoring\n", __func__)); + DBG_WARNING("talloc_realloc failed, ignoring\n"); return; } log->recs = tmp; @@ -669,7 +669,7 @@ static void notifyd_trigger(struct messaging_context *msg_ctx, return; } if (data->data[data->length-1] != 0) { - DEBUG(1, ("%s: path not 0-terminated, ignoring\n", __func__)); + DBG_WARNING("path not 0-terminated, ignoring\n");; return; } @@ -681,13 +681,15 @@ static void notifyd_trigger(struct messaging_context *msg_ctx, tstate.msg = (struct notify_trigger_msg *)data->data; path = tstate.msg->path; - DEBUG(10, ("%s: Got trigger_msg action=%u, filter=%u, path=%s\n", - __func__, (unsigned)tstate.msg->action, - (unsigned)tstate.msg->filter, path)); + DBG_DEBUG("Got trigger_msg action=%"PRIu32", filter=%"PRIu32", " + "path=%s\n", + tstate.msg->action, + tstate.msg->filter, + path); if (path[0] != '/') { - DEBUG(1, ("%s: path %s does not start with /, ignoring\n", - __func__, path)); + DBG_WARNING("path %s does not start with /, ignoring\n", + path); return; } @@ -699,8 +701,7 @@ static void notifyd_trigger(struct messaging_context *msg_ctx, next_p = strchr(p+1, '/'); tstate.recursive = (next_p != NULL); - DEBUG(10, ("%s: Trying path %.*s\n", __func__, - (int)path_len, path)); + DBG_DEBUG("Trying path %.*s\n", (int)path_len, path); key = (TDB_DATA) { .dptr = discard_const_p(uint8_t, path), .dsize = path_len }; @@ -748,13 +749,14 @@ static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data, if (!notifyd_parse_entry(data.dptr, data.dsize, &instances, &num_instances)) { - DEBUG(1, ("%s: Could not parse notifyd_entry\n", __func__)); + DBG_DEBUG("Could not parse notifyd_entry\n"); return; } - DEBUG(10, ("%s: Found %u instances for %.*s\n", __func__, - (unsigned)num_instances, (int)key.dsize, - (char *)key.dptr)); + DBG_DEBUG("Found %zu instances for %.*s\n", + num_instances, + (int)key.dsize, + (char *)key.dptr); iov[0].iov_base = &msg; iov[0].iov_len = offsetof(struct notify_event_msg, path); @@ -791,10 +793,9 @@ static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data, tstate->msg_ctx, instance->client, MSG_PVFS_NOTIFY, iov, ARRAY_SIZE(iov), NULL, 0); - DEBUG(10, ("%s: messaging_send_iov to %s returned %s\n", - __func__, - server_id_str_buf(instance->client, &idbuf), - nt_errstr(status))); + DBG_DEBUG("messaging_send_iov to %s returned %s\n", + server_id_str_buf(instance->client, &idbuf), + nt_errstr(status)); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) && procid_is_local(&instance->client)) { @@ -806,8 +807,8 @@ static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data, } if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("%s: messaging_send_iov returned %s\n", - __func__, nt_errstr(status))); + DBG_WARNING("messaging_send_iov returned %s\n", + nt_errstr(status)); } } } @@ -843,8 +844,8 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx, MSG_SMB_NOTIFY_REC_CHANGE, iov, ARRAY_SIZE(iov), NULL, 0); if (ret != 0) { - DEBUG(10, ("%s: messaging_send_iov_from returned %s\n", - __func__, strerror(ret))); + DBG_WARNING("messaging_send_iov_from returned %s\n", + strerror(ret)); } } @@ -866,17 +867,16 @@ static void notifyd_get_db(struct messaging_context *msg_ctx, buf = talloc_array(talloc_tos(), uint8_t, dbsize); if (buf == NULL) { - DEBUG(1, ("%s: talloc_array(%ju) failed\n", - __func__, (uintmax_t)dbsize)); + DBG_WARNING("talloc_array(%zu) failed\n", dbsize); return; } dbsize = dbwrap_marshall(state->entries, buf, dbsize); if (dbsize != talloc_get_size(buf)) { - DEBUG(1, ("%s: dbsize changed: %ju->%ju\n", __func__, - (uintmax_t)talloc_get_size(buf), - (uintmax_t)dbsize)); + DBG_DEBUG("dbsize changed: %zu->%zu\n", + talloc_get_size(buf), + dbsize); TALLOC_FREE(buf); return; } @@ -891,17 +891,17 @@ static void notifyd_get_db(struct messaging_context *msg_ctx, iov[1] = (struct iovec) { .iov_base = buf, .iov_len = dbsize }; - DEBUG(10, ("%s: Sending %ju bytes to %s->%s\n", __func__, - (uintmax_t)iov_buflen(iov, ARRAY_SIZE(iov)), - server_id_str_buf(messaging_server_id(msg_ctx), &id1), - server_id_str_buf(src, &id2))); + DBG_DEBUG("Sending %zu bytes to %s->%s\n", + iov_buflen(iov, ARRAY_SIZE(iov)), + server_id_str_buf(messaging_server_id(msg_ctx), &id1), + server_id_str_buf(src, &id2)); status = messaging_send_iov(msg_ctx, src, MSG_SMB_NOTIFY_DB, iov, ARRAY_SIZE(iov), NULL, 0); TALLOC_FREE(buf); if (!NT_STATUS_IS_OK(status)) { - DEBUG(1, ("%s: messaging_send_iov failed: %s\n", - __func__, nt_errstr(status))); + DBG_WARNING("messaging_send_iov failed: %s\n", + nt_errstr(status)); } } @@ -946,7 +946,7 @@ static void notifyd_got_db(struct messaging_context *msg_ctx, p->db = db_open_rbt(p); if (p->db == NULL) { - DEBUG(10, ("%s: db_open_rbt failed\n", __func__)); + DBG_DEBUG("db_open_rbt failed\n"); TALLOC_FREE(p); return; } @@ -954,9 +954,9 @@ static void notifyd_got_db(struct messaging_context *msg_ctx, status = dbwrap_unmarshall(p->db, data->data + 8, data->length - 8); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("%s: dbwrap_unmarshall returned %s for db %s\n", - __func__, nt_errstr(status), - server_id_str_buf(src, &idbuf))); + DBG_DEBUG("dbwrap_unmarshall returned %s for db %s\n", + nt_errstr(status), + server_id_str_buf(src, &idbuf)); TALLOC_FREE(p); return; } @@ -964,8 +964,9 @@ static void notifyd_got_db(struct messaging_context *msg_ctx, dbwrap_traverse_read(p->db, notifyd_add_proxy_syswatches, state, &count); - DEBUG(10, ("%s: Database from %s contained %d records\n", __func__, - server_id_str_buf(src, &idbuf), count)); + DBG_DEBUG("Database from %s contained %d records\n", + server_id_str_buf(src, &idbuf), + count); } static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, @@ -982,8 +983,9 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, return; } - DEBUG(10, ("%s: rec_index=%ju, num_recs=%u\n", __func__, - (uintmax_t)log->rec_index, (unsigned)log->num_recs)); + DBG_DEBUG("rec_index=%zu, num_recs=%"PRIu32"\n", + log->rec_index, + log->num_recs); message_hdr_put(msghdr, MSG_SMB_NOTIFY_REC_CHANGES, src, (struct server_id) {0 }); @@ -994,8 +996,8 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, &blob, log, log, (ndr_push_flags_fn_t)ndr_push_messaging_reclog); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - DEBUG(1, ("%s: ndr_push_messaging_recs failed: %s\n", - __func__, ndr_errstr(ndr_err))); + DBG_WARNING("ndr_push_messaging_recs failed: %s\n", + ndr_errstr(ndr_err)); goto done; } iov[1] = (struct iovec) { .iov_base = blob.data, @@ -1006,8 +1008,8 @@ static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn, CTDB_SRVID_SAMBA_NOTIFY_PROXY, iov, ARRAY_SIZE(iov)); TALLOC_FREE(blob.data); if (ret != 0) { - DEBUG(1, ("%s: ctdbd_messaging_send failed: %s\n", - __func__, strerror(ret))); + DBG_WARNING("ctdbd_messaging_send failed: %s\n", + strerror(ret)); goto done; } @@ -1145,8 +1147,8 @@ static void notifyd_clean_peers_next(struct tevent_req *subreq) * peer dead */ - DEBUG(10, ("%s: peer %s died\n", __func__, - server_id_str_buf(p->pid, &idbuf))); + DBG_DEBUG("peer %s died\n", + server_id_str_buf(p->pid, &idbuf)); /* * This implicitly decrements notifyd->num_peers */ @@ -1189,8 +1191,7 @@ static int notifyd_add_proxy_syswatches(struct db_record *rec, ok = notifyd_parse_entry(value.dptr, value.dsize, &instances, &num_instances); if (!ok) { - DEBUG(1, ("%s: Could not parse notifyd entry for %s\n", - __func__, path)); + DBG_WARNING("Could not parse notifyd entry for %s\n", path); return 0; } @@ -1213,8 +1214,8 @@ static int notifyd_add_proxy_syswatches(struct db_record *rec, notifyd_sys_callback, state->msg_ctx, &instance->sys_watch); if (ret != 0) { - DEBUG(1, ("%s: inotify_watch returned %s\n", - __func__, strerror(errno))); + DBG_WARNING("inotify_watch returned %s\n", + strerror(errno)); } } @@ -1233,8 +1234,8 @@ static int notifyd_db_del_syswatches(struct db_record *rec, void *private_data) ok = notifyd_parse_entry(value.dptr, value.dsize, &instances, &num_instances); if (!ok) { - DEBUG(1, ("%s: Could not parse notifyd entry for %.*s\n", - __func__, (int)key.dsize, (char *)key.dptr)); + DBG_WARNING("Could not parse notifyd entry for %.*s\n", + (int)key.dsize, (char *)key.dptr); return 0; } for (i=0; inum_recs, (uintmax_t)log->rec_index, - server_id_str_buf(peer->pid, &idbuf))); + DBG_DEBUG("Got %"PRIu32" recs index %"PRIu64" from %s\n", + log->num_recs, + log->rec_index, + server_id_str_buf(peer->pid, &idbuf)); if (log->rec_index != peer->rec_index) { - DEBUG(3, ("%s: Got rec index %ju from %s, expected %ju\n", - __func__, (uintmax_t)log->rec_index, - server_id_str_buf(peer->pid, &idbuf), - (uintmax_t)peer->rec_index)); + DBG_INFO("Got rec index %"PRIu64" from %s, " + "expected %"PRIu64"\n", + log->rec_index, + server_id_str_buf(peer->pid, &idbuf), + peer->rec_index); goto fail; } @@ -1345,8 +1348,7 @@ static void notifyd_apply_reclog(struct notifyd_peer *peer, ok = notifyd_parse_rec_change(r->buf.data, r->buf.length, &chg, &pathlen); if (!ok) { - DEBUG(3, ("%s: notifyd_parse_rec_change failed\n", - __func__)); + DBG_INFO("notifyd_parse_rec_change failed\n"); goto fail; } @@ -1359,8 +1361,7 @@ static void notifyd_apply_reclog(struct notifyd_peer *peer, state->sys_notify_ctx, state->msg_ctx); if (!ok) { - DEBUG(3, ("%s: notifyd_apply_rec_change failed\n", - __func__)); + DBG_INFO("notifyd_apply_rec_change failed\n"); goto fail; } } @@ -1372,8 +1373,8 @@ static void notifyd_apply_reclog(struct notifyd_peer *peer, return; fail: - DEBUG(10, ("%s: Dropping peer %s\n", __func__, - server_id_str_buf(peer->pid, &idbuf))); + DBG_DEBUG("Dropping peer %s\n", + server_id_str_buf(peer->pid, &idbuf)); TALLOC_FREE(peer); } @@ -1412,29 +1413,27 @@ static int notifyd_snoop_broadcast(struct tevent_context *ev, NTSTATUS status; if (msglen < MESSAGE_HDR_LENGTH) { - DEBUG(10, ("%s: Got short broadcast\n", __func__)); + DBG_DEBUG("Got short broadcast\n"); return 0; } message_hdr_get(&msg_type, &src, &dst, msg); if (msg_type != MSG_SMB_NOTIFY_REC_CHANGES) { - DEBUG(10, ("%s Got message %u, ignoring\n", __func__, - (unsigned)msg_type)); + DBG_DEBUG("Got message %"PRIu32", ignoring\n", msg_type); return 0; } if (server_id_equal(&src, &my_id)) { - DEBUG(10, ("%s: Ignoring my own broadcast\n", __func__)); + DBG_DEBUG("Ignoring my own broadcast\n"); return 0; } - DEBUG(10, ("%s: Got MSG_SMB_NOTIFY_REC_CHANGES from %s\n", - __func__, server_id_str_buf(src, &idbuf))); + DBG_DEBUG("Got MSG_SMB_NOTIFY_REC_CHANGES from %s\n", + server_id_str_buf(src, &idbuf)); for (i=0; inum_peers; i++) { if (server_id_equal(&state->peers[i]->pid, &src)) { - DEBUG(10, ("%s: Applying changes to peer %u\n", - __func__, (unsigned)i)); + DBG_DEBUG("Applying changes to peer %"PRIu32"\n", i); notifyd_apply_reclog(state->peers[i], msg + MESSAGE_HDR_LENGTH, @@ -1443,20 +1442,20 @@ static int notifyd_snoop_broadcast(struct tevent_context *ev, } } - DEBUG(10, ("%s: Creating new peer for %s\n", __func__, - server_id_str_buf(src, &idbuf))); + DBG_DEBUG("Creating new peer for %s\n", + server_id_str_buf(src, &idbuf)); p = notifyd_peer_new(state, src); if (p == NULL) { - DEBUG(10, ("%s: notifyd_peer_new failed\n", __func__)); + DBG_DEBUG("notifyd_peer_new failed\n"); return 0; } status = messaging_send_buf(state->msg_ctx, src, MSG_SMB_NOTIFY_GET_DB, NULL, 0); if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("%s: messaging_send_buf failed: %s\n", - __func__, nt_errstr(status))); + DBG_DEBUG("messaging_send_buf failed: %s\n", + nt_errstr(status)); TALLOC_FREE(p); return 0; } @@ -1489,8 +1488,7 @@ static bool notifyd_parse_db_parser(TDB_DATA key, TDB_DATA value, ok = notifyd_parse_entry(value.dptr, value.dsize, &instances, &num_instances); if (!ok) { - DEBUG(10, ("%s: Could not parse entry for path %s\n", - __func__, path)); + DBG_DEBUG("Could not parse entry for path %s\n", path); return true; }