From 4c0f6f185ec5ee891c5ec45fc378c117d4d2edcd Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 14 Aug 2009 22:28:33 +0200 Subject: [PATCH] Lets first output statistics before freeing them. Saves a rather stupid segmentation fault. --- bacula/src/filed/restore.c | 87 +++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index 7c45f51346..470dbb08e0 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -733,7 +733,42 @@ bail_out: set_jcr_job_status(jcr, JS_ErrorTerminated); ok_out: - /* Free Signature & Crypto Data */ + /* + * First output the statistics. + */ + Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles, + edit_uint64(jcr->JobBytes, ec1)); + if (jcr->acl_data->nr_errors > 0) { + Jmsg(jcr, M_ERROR, 0, _("Encountered %ld acl errors while doing restore\n"), + jcr->acl_data->nr_errors); + } + if (jcr->xattr_data->nr_errors > 0) { + Jmsg(jcr, M_ERROR, 0, _("Encountered %ld xattr errors while doing restore\n"), + jcr->xattr_data->nr_errors); + } + if (non_support_data > 1 || non_support_attr > 1) { + Jmsg(jcr, M_ERROR, 0, _("%d non-supported data streams and %d non-supported attrib streams ignored.\n"), + non_support_data, non_support_attr); + } + if (non_support_rsrc) { + Jmsg(jcr, M_INFO, 0, _("%d non-supported resource fork streams ignored.\n"), non_support_rsrc); + } + if (non_support_finfo) { + Jmsg(jcr, M_INFO, 0, _("%d non-supported Finder Info streams ignored.\n"), non_support_rsrc); + } + if (non_support_acl) { + Jmsg(jcr, M_INFO, 0, _("%d non-supported acl streams ignored.\n"), non_support_acl); + } + if (non_support_crypto) { + Jmsg(jcr, M_INFO, 0, _("%d non-supported crypto streams ignored.\n"), non_support_acl); + } + if (non_support_xattr) { + Jmsg(jcr, M_INFO, 0, _("%d non-supported xattr streams ignored.\n"), non_support_xattr); + } + + /* + * Free Signature & Crypto Data + */ free_signature(rctx); free_session(rctx); if (jcr->crypto.digest) { @@ -741,17 +776,22 @@ ok_out: jcr->crypto.digest = NULL; } - /* Free file cipher restore context */ + /* + * Free file cipher restore context + */ if (rctx.cipher_ctx.cipher) { crypto_cipher_free(rctx.cipher_ctx.cipher); rctx.cipher_ctx.cipher = NULL; } + if (rctx.cipher_ctx.buf) { free_pool_memory(rctx.cipher_ctx.buf); rctx.cipher_ctx.buf = NULL; } - /* Free alternate stream cipher restore context */ + /* + * Free alternate stream cipher restore context + */ if (rctx.fork_cipher_ctx.cipher) { crypto_cipher_free(rctx.fork_cipher_ctx.cipher); rctx.fork_cipher_ctx.cipher = NULL; @@ -767,50 +807,21 @@ ok_out: jcr->compress_buf_size = 0; } - if (have_xattr && jcr->xattr_data) { - free_pool_memory(jcr->xattr_data->content); - free(jcr->xattr_data); - jcr->xattr_data = NULL; - } if (have_acl && jcr->acl_data) { free_pool_memory(jcr->acl_data->content); free(jcr->acl_data); jcr->acl_data = NULL; } + if (have_xattr && jcr->xattr_data) { + free_pool_memory(jcr->xattr_data->content); + free(jcr->xattr_data); + jcr->xattr_data = NULL; + } + bclose(&rctx.forkbfd); bclose(&rctx.bfd); free_attr(rctx.attr); - Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles, - edit_uint64(jcr->JobBytes, ec1)); - if (jcr->acl_data->nr_errors > 0) { - Jmsg(jcr, M_ERROR, 0, _("Encountered %ld acl errors while doing restore\n"), - jcr->acl_data->nr_errors); - } - if (jcr->xattr_data->nr_errors > 0) { - Jmsg(jcr, M_ERROR, 0, _("Encountered %ld xattr errors while doing restore\n"), - jcr->xattr_data->nr_errors); - } - if (non_support_data > 1 || non_support_attr > 1) { - Jmsg(jcr, M_ERROR, 0, _("%d non-supported data streams and %d non-supported attrib streams ignored.\n"), - non_support_data, non_support_attr); - } - if (non_support_rsrc) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported resource fork streams ignored.\n"), non_support_rsrc); - } - if (non_support_finfo) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported Finder Info streams ignored.\n"), non_support_rsrc); - } - if (non_support_acl) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported acl streams ignored.\n"), non_support_acl); - } - if (non_support_crypto) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported crypto streams ignored.\n"), non_support_acl); - } - if (non_support_xattr) { - Jmsg(jcr, M_INFO, 0, _("%d non-supported xattr streams ignored.\n"), non_support_xattr); - } - } #ifdef HAVE_LIBZ -- 2.39.5