]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
sort: destroy spin locks portably
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 Sep 2010 22:44:31 +0000 (15:44 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 20 Sep 2010 22:45:49 +0000 (15:45 -0700)
* src/sort.c (sortlines, sort): Use pthread_spin_destroy when a
spin lock is no longer used.  This isn't needed on GNU/Linux or
Solaris, but POSIX says it may free up resources on some platforms.

src/sort.c

index a8d0c142bfffefad7eeb9db10c58b811232ae9b3..89f7be32c8ba68a50b1844bb92421f19e09f10ca 100644 (file)
@@ -3480,6 +3480,8 @@ sortlines (struct line *restrict lines, struct line *restrict dest,
       queue_insert (merge_queue, &node);
       merge_loop (merge_queue, total_lines, tfp, temp_output);
     }
+
+  pthread_spin_destroy (&lock);
 }
 
 /* Scan through FILES[NTEMPS .. NFILES-1] looking for a file that is
@@ -3765,6 +3767,7 @@ sort (char * const *files, size_t nfiles, char const *output_file,
               sortlines (line, line, nthreads, buf.nlines, &node, true,
                          &merge_queue, tfp, temp_output);
               queue_destroy (&merge_queue);
+              pthread_spin_destroy (&lock);
             }
           else
             write_unique (line - 1, tfp, temp_output);