]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
mount_image.c: Minor cleanups
[wimlib] / src / mount_image.c
index 3f5c6cfc5b5897e01c0dff69d8bb12a56dc56ce9..6a38dc33e8cabbfb7b0dce837052a18bc28650a9 100644 (file)
@@ -1017,7 +1017,6 @@ enum {
 };
 
 struct msg_handler_context {
-       bool is_daemon;
        int timeout_seconds;
        union {
                struct {
@@ -1108,7 +1107,8 @@ static int unmount_progress_func(enum wimlib_progress_msg msg,
                if (mq_send(wimfs_get_context()->daemon_to_unmount_mq,
                            (void*)&msg, sizeof(msg), 1))
                {
-                       ERROR_WITH_ERRNO("Failed to send status to unmount process");
+                       ERROR_WITH_ERRNO("Failed to send progress information "
+                                        "to unmount process");
                }
        }
        return 0;
@@ -1122,6 +1122,7 @@ static int msg_unmount_request_handler(const void *_msg,
        int status = 0;
        int ret;
        int unmount_flags;
+       wimlib_progress_func_t progress_func;
 
        DEBUG("Handling unmount request msg");
 
@@ -1134,6 +1135,10 @@ static int msg_unmount_request_handler(const void *_msg,
        }
 
        unmount_flags = msg->unmount_flags;
+       if (msg->want_progress_messages)
+               progress_func = unmount_progress_func;
+       else
+               progress_func = NULL;
 
        ret = send_daemon_info_msg(wimfs_ctx->daemon_to_unmount_mq, getpid(),
                                   wimfs_ctx->mount_flags);
@@ -1152,7 +1157,7 @@ static int msg_unmount_request_handler(const void *_msg,
                        if (unmount_flags & WIMLIB_UNMOUNT_FLAG_RECOMPRESS)
                                write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
                        status = rebuild_wim(wimfs_ctx, write_flags,
-                                            unmount_progress_func);
+                                            progress_func);
                }
        } else {
                DEBUG("Read-only mount");
@@ -1236,7 +1241,8 @@ out_crashed:
 
 static int daemon_timed_out_cb(struct msg_handler_context *handler_ctx)
 {
-       DEBUG("Timed out");
+       ERROR("Timed out waiting for unmount request! "
+             "Changes to the mounted WIM will not be committed.");
        return WIMLIB_ERR_TIMEOUT;
 }
 
@@ -1451,26 +1457,19 @@ static int wimfs_chmod(const char *path, mode_t mask)
 /* Called when the filesystem is unmounted. */
 static void wimfs_destroy(void *p)
 {
-       struct wimfs_context *wimfs_ctx;
-
-       wimfs_ctx = wimfs_get_context();
-
-       if (open_message_queues(wimfs_ctx, true))
-               return;
-
-       struct msg_handler_context handler_ctx = {
-               .is_daemon = true,
-               .timeout_seconds = 5,
-               .daemon = {
-                       .wimfs_ctx = wimfs_ctx,
-               },
-       };
-
-       message_loop(wimfs_ctx->unmount_to_daemon_mq,
-                    &daemon_msg_handler_callbacks,
-                    &handler_ctx);
-
-       close_message_queues(wimfs_ctx);
+       struct wimfs_context *wimfs_ctx = wimfs_get_context();
+       if (open_message_queues(wimfs_ctx, true) == 0) {
+               struct msg_handler_context handler_ctx = {
+                       .timeout_seconds = 5,
+                       .daemon = {
+                               .wimfs_ctx = wimfs_ctx,
+                       },
+               };
+               message_loop(wimfs_ctx->unmount_to_daemon_mq,
+                            &daemon_msg_handler_callbacks,
+                            &handler_ctx);
+               close_message_queues(wimfs_ctx);
+       }
 }
 
 #if 0
@@ -2518,7 +2517,6 @@ WIMLIBAPI int wimlib_unmount_image(const char *dir, int unmount_flags,
                goto out_close_message_queues;
 
        struct msg_handler_context handler_ctx = {
-               .is_daemon = false,
                .timeout_seconds = 5,
                .unmount = {
                        .daemon_pid = 0,