File pacemaker-libcluster-libcrmcommon-improve-BZ2-error-messages.patch of Package pacemaker.14737
commit 8ac666968562e167026bdb3e2dd31efcb09ed260
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Mon Jan 8 14:00:51 2018 -0600
Log: libcluster,libcrmcommon: improve BZ2 error messages
Index: pacemaker/lib/cluster/cpg.c
===================================================================
--- pacemaker.orig/lib/cluster/cpg.c
+++ pacemaker/lib/cluster/cpg.c
@@ -301,7 +301,8 @@ pcmk_message_common_cs(cpg_handle_t hand
rc = BZ2_bzBuffToBuffDecompress(uncompressed, &new_size, msg->data, msg->compressed_size, 1, 0);
if (rc != BZ_OK) {
- crm_err("Decompression failed: %d", rc);
+ crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+ bz2_strerror(rc), rc);
free(uncompressed);
goto badmsg;
}
Index: pacemaker/lib/common/ipc.c
===================================================================
--- pacemaker.orig/lib/common/ipc.c
+++ pacemaker/lib/common/ipc.c
@@ -439,7 +439,8 @@ crm_ipcs_recv(crm_client_t * c, void *da
text = uncompressed;
if (rc != BZ_OK) {
- crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+ crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+ bz2_strerror(rc), rc);
free(uncompressed);
return NULL;
}
@@ -983,7 +984,8 @@ crm_ipc_decompress(crm_ipc_t * client)
client->buffer + hdr_offset, header->size_compressed, 1, 0);
if (rc != BZ_OK) {
- crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+ crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+ bz2_strerror(rc), rc);
free(uncompressed);
return -EILSEQ;
}
Index: pacemaker/lib/common/remote.c
===================================================================
--- pacemaker.orig/lib/common/remote.c
+++ pacemaker/lib/common/remote.c
@@ -411,7 +411,8 @@ crm_remote_parse_buffer(crm_remote_t * r
return NULL;
} else if (rc != BZ_OK) {
- crm_err("Decompression failed: %s (%d)", bz2_strerror(rc), rc);
+ crm_err("Decompression failed: %s " CRM_XS " bzerror=%d",
+ bz2_strerror(rc), rc);
free(uncompressed);
return NULL;
}
Index: pacemaker/lib/common/utils.c
===================================================================
--- pacemaker.orig/lib/common/utils.c
+++ pacemaker/lib/common/utils.c
@@ -2405,7 +2405,8 @@ crm_compress_string(const char *data, in
free(uncompressed);
if (rc != BZ_OK) {
- crm_err("Compression of %d bytes failed: %s (%d)", length, bz2_strerror(rc), rc);
+ crm_err("Compression of %d bytes failed: %s " CRM_XS " bzerror=%d",
+ length, bz2_strerror(rc), rc);
free(compressed);
return FALSE;
}
Index: pacemaker/lib/common/xml.c
===================================================================
--- pacemaker.orig/lib/common/xml.c
+++ pacemaker/lib/common/xml.c
@@ -3174,8 +3174,9 @@ decompress_file(const char *filename)
}
bz_file = BZ2_bzReadOpen(&rc, input, 0, 0, NULL, 0);
-
if (rc != BZ_OK) {
+ crm_err("Could not prepare to read compressed %s: %s "
+ CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
BZ2_bzReadClose(&rc, bz_file);
return NULL;
}
@@ -3195,7 +3196,8 @@ decompress_file(const char *filename)
buffer[length] = '\0';
if (rc != BZ_STREAM_END) {
- crm_err("Couldn't read compressed xml from file");
+ crm_err("Could not read compressed %s: %s "
+ CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
free(buffer);
buffer = NULL;
}
@@ -3204,7 +3206,8 @@ decompress_file(const char *filename)
fclose(input);
#else
- crm_err("Cannot read compressed files:" " bzlib was not available at compile time");
+ crm_err("Could not read compressed %s: not built with bzlib support",
+ filename);
#endif
return buffer;
}
@@ -3272,7 +3275,8 @@ filename2xml(const char *filename)
} else {
char *input = decompress_file(filename);
- output = xmlCtxtReadDoc(ctxt, (const xmlChar *)input, NULL, NULL, xml_options);
+ output = xmlCtxtReadDoc(ctxt, (const xmlChar *)input, NULL, NULL,
+ xml_options);
free(input);
}
@@ -3354,21 +3358,23 @@ write_xml_stream(xmlNode * xml_node, con
bz_file = BZ2_bzWriteOpen(&rc, stream, 5, 0, 30);
if (rc != BZ_OK) {
- crm_warn("Not compressing %s: could not prepare file stream "
- CRM_XS " bzerror=%d", filename, rc);
+ crm_warn("Not compressing %s: could not prepare file stream: %s "
+ CRM_XS " bzerror=%d", filename, bz2_strerror(rc), rc);
} else {
BZ2_bzWrite(&rc, bz_file, buffer, strlen(buffer));
if (rc != BZ_OK) {
- crm_warn("Not compressing %s: could not compress data "
- CRM_XS " bzerror=%d errno=%d", filename, rc, errno);
+ crm_warn("Not compressing %s: could not compress data: %s "
+ CRM_XS " bzerror=%d errno=%d",
+ filename, bz2_strerror(rc), rc, errno);
}
}
if (rc == BZ_OK) {
BZ2_bzWriteClose(&rc, bz_file, 0, &in, &out);
if (rc != BZ_OK) {
- crm_warn("Not compressing %s: could not write compressed data "
- CRM_XS " bzerror=%d errno=%d", filename, rc, errno);
+ crm_warn("Not compressing %s: could not write compressed data: %s "
+ CRM_XS " bzerror=%d errno=%d",
+ filename, bz2_strerror(rc), rc, errno);
out = -1; // retry without compression
} else {
res = (int) out;