Commit 1078198e authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

jsonrpc_server: Remove newlines only if JSON RPC logging is enabled



We removed newlines by default when JSON RPC logging is supported
because newlines do not affect the functionality of JSON RPC objects.
However, this change lost backward compatibility of some custom
applications which enabled SPDK_JSON_PARSE_FLAG_ALLOW_COMMENTS.

JSON RPC logging is an optional feature. Hence, as a workaround we
remove newlines only if JSON RPC logging is enabled.

Fixes github issue #3155

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I3c7bd0b5b0fc27538c22b6fa10a67fd2a6e5895d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20505


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 0bfa2536
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -48,11 +48,13 @@ remove_newlines(char *text)
static void
jsonrpc_log(char *buf, const char *prefix)
{
	/* Remove newlines to print in a single line.
	 * Newlines does not affect the functionality of JSON RPC objects.
	 * Hence for simplicity, remove newlines by default.
	/* Some custom applications have enabled SPDK_JSON_PARSE_FLAG_ALLOW_COMMENTS
	 * to allow comments in JSON RPC objects. To keep backward compatibility of
	 * these applications, remove newlines only if JSON RPC logging is enabled.
	 */
	if (g_rpc_log_level != SPDK_LOG_DISABLED || g_rpc_log_file != NULL) {
		remove_newlines(buf);
	}

	if (g_rpc_log_level != SPDK_LOG_DISABLED) {
		spdk_log(g_rpc_log_level, NULL, 0, NULL, "%s%s\n", prefix, buf);