]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - command.c
command.c: Open-code mmd_dup().
[paraslash.git] / command.c
index 46ede2fe825a9c10c86f59dd6c4e2f244d653468..bde1458776856d26be371da2e309fb21354c5078 100644 (file)
--- a/command.c
+++ b/command.c
@@ -75,13 +75,6 @@ static void dummy(__a_unused int s)
 {
 }
 
-static void mmd_dup(struct misc_meta_data *new_mmd)
-{
-       mutex_lock(mmd_mutex);
-       *new_mmd = *mmd;
-       mutex_unlock(mmd_mutex);
-}
-
 /*
  * Compute human readable vss status text.
  *
@@ -533,7 +526,13 @@ static int com_stat(struct command_context *cc)
        if (i != cc->argc)
                return -E_COMMAND_SYNTAX;
        for (;;) {
-               mmd_dup(nmmd);
+               /*
+                * Copy the mmd structure to minimize the time we hold the mmd
+                * lock.
+                */
+               mutex_lock(mmd_mutex);
+               *nmmd = *mmd;
+               mutex_unlock(mmd_mutex);
                ret = get_status(nmmd, parser_friendly, &s);
                ret = send_sb(&cc->scc, s, ret, SBD_OUTPUT, false);
                if (ret < 0)