summaryrefslogtreecommitdiff
path: root/tumblerd/tumbler-registry.c
blob: 6f75654a7588a4967b439a549701131a30641dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
 * Copyright (c) 2009-2011 Jannis Pohlmann <jannis@xfce.org>
 * Copyright (c) 2018      Ali Abdallah    <ali@xfce.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <glib-object.h>


#include <tumbler/tumbler.h>

#include <tumblerd/tumbler-registry.h>
#include <tumblerd/tumbler-specialized-thumbnailer.h>
#include <tumblerd/tumbler-utils.h>


static void                tumbler_registry_finalize                  (GObject            *object);
static void                tumbler_registry_remove_thumbnailer        (const gchar        *key,
                                                                       GList             **list,
                                                                       TumblerThumbnailer *thumbnailer);
static void                tumbler_registry_list_free                 (gpointer            data);
static GList              *tumbler_registry_get_thumbnailers_internal (TumblerRegistry    *registry);
static gint                tumbler_registry_compare                   (TumblerThumbnailer *a,
                                                                       TumblerThumbnailer *b);
static GList              *tumbler_registry_lookup                    (TumblerRegistry    *registry,
                                                                       const gchar        *hash_key);



struct _TumblerRegistryClass
{
  GObjectClass __parent__;
};

struct _TumblerRegistry
{
  GObject       __parent__;

  GHashTable   *thumbnailers;
  GHashTable   *preferred_thumbnailers;
  TUMBLER_MUTEX (mutex);

  gchar       **uri_schemes;
  gchar       **mime_types;
};



G_DEFINE_TYPE (TumblerRegistry, tumbler_registry, G_TYPE_OBJECT);



GQuark tumbler_registry_visited_quark;



static void
tumbler_registry_class_init (TumblerRegistryClass *klass)
{
  GObjectClass *gobject_class;

  /* pre-allocate the required quarks */
  tumbler_registry_visited_quark =
    g_quark_from_static_string ("tumbler-registry-visited-quark");

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->finalize = tumbler_registry_finalize;
}



static void
tumbler_registry_init (TumblerRegistry *registry)
{
  tumbler_mutex_create (registry->mutex);
  registry->thumbnailers = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                  g_free, tumbler_registry_list_free);
  registry->preferred_thumbnailers = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                            g_free, g_object_unref);
}



static void
tumbler_registry_finalize (GObject *object)
{
  TumblerRegistry *registry = TUMBLER_REGISTRY (object);

  /* release all thumbnailers */
  g_hash_table_unref (registry->preferred_thumbnailers);
  g_hash_table_unref (registry->thumbnailers);

  /* free the cached URI schemes and MIME types */
  g_strfreev (registry->uri_schemes);
  g_strfreev (registry->mime_types);

  /* destroy the mutex */
  tumbler_mutex_free (registry->mutex);

  (*G_OBJECT_CLASS (tumbler_registry_parent_class)->finalize) (object);
}



static void
tumbler_registry_remove_thumbnailer (const gchar        *key,
                                     GList             **list,
                                     TumblerThumbnailer *thumbnailer)
{
  GList *lp;

  for (lp = *list; lp != NULL; lp = lp->next)
    {
      if (lp->data == thumbnailer)
        {
          g_object_unref (lp->data);
          *list = g_list_delete_link (*list, lp);
          break;
        }
    }
}



static gint
tumbler_registry_compare (TumblerThumbnailer *a,
                          TumblerThumbnailer *b)
{
  TumblerSpecializedThumbnailer *a_specialized;
  TumblerSpecializedThumbnailer *b_specialized;
  gboolean                       insert_a_before_b = FALSE;
  gboolean                       a_foreign;
  gboolean                       b_foreign;
  guint64                        a_modified;
  guint64                        b_modified;

  g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (a), 0);
  g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (b), 0);

  /* TODO Rewrite this based on a single get_registered() time function
   * for all thumbnailer types */

  if (!TUMBLER_IS_SPECIALIZED_THUMBNAILER (a) || !TUMBLER_IS_SPECIALIZED_THUMBNAILER (b))
    {
      /* sort by priority */
      insert_a_before_b = tumbler_thumbnailer_get_priority (a) >= tumbler_thumbnailer_get_priority (b);
    }
  else
    {
      a_specialized = TUMBLER_SPECIALIZED_THUMBNAILER (a);
      b_specialized = TUMBLER_SPECIALIZED_THUMBNAILER (b);

      a_foreign = tumbler_specialized_thumbnailer_get_foreign (a_specialized);
      b_foreign = tumbler_specialized_thumbnailer_get_foreign (b_specialized);

      if (a_foreign || b_foreign)
        {
          /* both thumbnailers were registered dynamically over D-Bus but
           * whoever goes last wins */
          insert_a_before_b = TRUE;
        }
      else
        {
          a_modified = tumbler_specialized_thumbnailer_get_modified (a_specialized);
          b_modified = tumbler_specialized_thumbnailer_get_modified (b_specialized);

          if (a_modified > b_modified)
            {
              /* a and b are both specialized thumbnailers but a was installed
               * on the system last, so it wins */
              insert_a_before_b = TRUE;
            }
        }
    }

  return insert_a_before_b ? -1 : 1;
}



static void tumbler_registry_list_free (gpointer data)
{
  GList **list = data;

  /* free the list, its contents and the pointer to it */
  g_list_free_full (*list, g_object_unref);
  g_free (list);
}



static GList *
tumbler_registry_get_thumbnailers_internal (TumblerRegistry *registry)
{
  GList **list;
  GList  *thumbnailers = NULL;
  GList  *lists;
  GList  *lp;

  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), NULL);

  /* get the thumbnailer lists */
  lists = g_hash_table_get_values (registry->thumbnailers);

  for (lp = lists; lp != NULL; lp = lp->next)
    {
      list = lp->data;

      /* add the first thumbnailer of each list to the output list */
      if (list != NULL && *list != NULL)
        thumbnailers = g_list_prepend (thumbnailers, g_object_ref ((*list)->data));
    }

  /* release the thumbnailer list */
  g_list_free (lists);

  return thumbnailers;
}



static GList *
tumbler_registry_lookup (TumblerRegistry *registry,
                         const gchar     *hash_key)
{
  TumblerThumbnailer *thumbnailer = NULL;
  GList             **list;
  GList              *available = NULL;
  GList              *lp;

  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), NULL);
  g_return_val_if_fail (hash_key != NULL, NULL);

  thumbnailer = g_hash_table_lookup (registry->preferred_thumbnailers, hash_key);
  if (thumbnailer != NULL)
    {
      g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (available), NULL);
      available = g_list_prepend (available, g_object_ref (thumbnailer));
    }

  list = g_hash_table_lookup (registry->thumbnailers, hash_key);
  if (list != NULL)
    {
      for (lp = *list; lp != NULL; lp = lp->next)
        {
          g_return_val_if_fail (TUMBLER_IS_THUMBNAILER (lp->data), NULL);
          available = g_list_prepend (available, g_object_ref (lp->data));
        }
    }

  return g_list_reverse (available);
}



static gint64
tumbler_registry_get_file_size (GFile *gfile)
{
  GFileInfo *file_info;
  gint64     size = 0;

  g_return_val_if_fail (G_IS_FILE (gfile), 0);

  file_info = g_file_query_info (gfile,
                                 G_FILE_ATTRIBUTE_STANDARD_SIZE,
                                 G_FILE_QUERY_INFO_NONE, NULL, NULL);
  if (file_info != NULL)
    {
      size = g_file_info_get_size (file_info);
      g_object_unref (file_info);
    }

  return size;
}



TumblerRegistry *
tumbler_registry_new (void)
{
  return g_object_new (TUMBLER_TYPE_REGISTRY, NULL);
}



gboolean
tumbler_registry_load (TumblerRegistry *registry,
                       GError         **error)
{
  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  /* TODO */

  return TRUE;
}



void
tumbler_registry_add (TumblerRegistry    *registry,
                      TumblerThumbnailer *thumbnailer)
{
  GList **list;
  gchar **hash_keys;
  gint    n;

  g_return_if_fail (TUMBLER_IS_REGISTRY (registry));
  g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));

  tumbler_mutex_lock (registry->mutex);

  /* determine the hash keys (all combinations of URI schemes and MIME types)
   * for this thumbnailer */
  hash_keys = tumbler_thumbnailer_get_hash_keys (thumbnailer);

  /* iterate over all of them */
  for (n = 0; hash_keys != NULL && hash_keys[n] != NULL; ++n)
    {
      /* fetch the thumbnailer list for this URI scheme/MIME type combination */
      list = g_hash_table_lookup (registry->thumbnailers, hash_keys[n]);

      if (list != NULL)
        {
          /* we already have thumbnailers for this combination. insert the new
           * one at the right position in the list */
          *list = g_list_insert_sorted (*list, g_object_ref (thumbnailer),
                                        (GCompareFunc) tumbler_registry_compare);
        }
      else
        {
          /* allocate a new list */
          list = g_new0 (GList *, 1);

          /* insert the thumbnailer into the list */
          *list = g_list_prepend (*list, g_object_ref (thumbnailer));

          /* insert the pointer to the list in the hash table */
          g_hash_table_insert (registry->thumbnailers, g_strdup (hash_keys[n]), list);
        }
    }

  /* connect to the unregister signal of the thumbnailer */
  g_signal_connect_swapped (thumbnailer, "unregister",
                            G_CALLBACK (tumbler_registry_remove), registry);

  g_strfreev (hash_keys);

  tumbler_mutex_unlock (registry->mutex);
}



void
tumbler_registry_remove (TumblerRegistry    *registry,
                         TumblerThumbnailer *thumbnailer)
{
  g_return_if_fail (TUMBLER_IS_REGISTRY (registry));
  g_return_if_fail (TUMBLER_IS_THUMBNAILER (thumbnailer));

  tumbler_mutex_lock (registry->mutex);

  g_signal_handlers_disconnect_matched (thumbnailer, G_SIGNAL_MATCH_DATA,
                                        0, 0, NULL, NULL, registry);

  /* remove the thumbnailer from all hash key lists */
  g_hash_table_foreach (registry->thumbnailers,
                        (GHFunc) tumbler_registry_remove_thumbnailer, thumbnailer);

  tumbler_mutex_unlock (registry->mutex);
}



GList *
tumbler_registry_get_thumbnailers (TumblerRegistry *registry)
{
  GList *thumbnailers;

  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), NULL);

  tumbler_mutex_lock (registry->mutex);

  thumbnailers = tumbler_registry_get_thumbnailers_internal (registry);

  tumbler_mutex_unlock (registry->mutex);

  /* return all active thumbnailers */
  return thumbnailers;
}



GList **
tumbler_registry_get_thumbnailer_array (TumblerRegistry    *registry,
                                        TumblerFileInfo   **infos,
                                        guint               length)
{
  GList              **thumbnailers = NULL;
  gchar               *hash_key;
  gchar               *scheme;
  guint                n;
  GList               *list, *lp;
  GFile               *gfile;
  gint64               file_size;
  gint64               max_file_size;
  const gchar         *uri;

  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), NULL);
  g_return_val_if_fail (infos != NULL, NULL);

  tumbler_mutex_lock (registry->mutex);

  /* allocate the thumbnailer array */
  thumbnailers = g_new0 (GList *, length + 1);

  /* iterate over all URIs */
  for (n = 0; n < length; ++n)
    {
      g_assert (TUMBLER_IS_FILE_INFO (infos[n]));

      /* reset */
      file_size = 0;

      /* determine the URI scheme and generate a hash key */
      uri = tumbler_file_info_get_uri (infos[n]);
      gfile = g_file_new_for_uri (uri);
      scheme = g_file_get_uri_scheme (gfile);
      hash_key = g_strdup_printf ("%s-%s", scheme,
                                  tumbler_file_info_get_mime_type (infos[n]));

      /* get list of thumbnailer that can handle this URI/MIME type pair */
      list = tumbler_registry_lookup (registry, hash_key);
      for (lp = list; lp != NULL; lp = lp->next)
        {
          /* check if the file size is a limitation */
          max_file_size = tumbler_thumbnailer_get_max_file_size (lp->data);
          if (max_file_size > 0)
            {
              /* load the source's size on demand */
              if (file_size == 0)
                file_size = tumbler_registry_get_file_size (gfile);
              if (file_size > max_file_size)
                {
                  g_debug ("URI '%s' filtered by size in config file", uri);
                  continue;
                }
            }

          /* check if the location is supported */
          if (!tumbler_thumbnailer_supports_location (lp->data, gfile))
            {
              g_debug ("URI '%s' filtered by location in config file", uri);
              continue;
            }

          /* found a usable thumbnailer */
          thumbnailers[n] = g_list_prepend (thumbnailers[n], g_object_ref (lp->data));
        }

      /* restore thumbnailer priority */
      thumbnailers[n] = g_list_reverse (thumbnailers[n]);

      /* cleanup */
      g_free (hash_key);
      g_free (scheme);
      g_object_unref (gfile);
      g_list_free_full (list, g_object_unref);
    }

  /* NULL-terminate the array */
  thumbnailers[n] = NULL;

  tumbler_mutex_unlock (registry->mutex);

  return thumbnailers;
}



static void
free_pair (gpointer data)
{
  g_slice_free1 (2 * sizeof (const gchar *), data);
}



void
tumbler_registry_update_supported (TumblerRegistry *registry)
{
  GHashTableIter iter;
  GHashTable    *unique_pairs;
  GPtrArray     *used_strings;
  GList         *thumbnailers;
  GList         *lp;
  const gchar  **pair;
  gchar         *pair_string;
  gchar        **mime_types;
  gchar        **uri_schemes;
  gint           n;
  gint           u;

  g_return_if_fail (TUMBLER_IS_REGISTRY (registry));

  tumbler_mutex_lock (registry->mutex);

  /* free the old cache */
  g_strfreev (registry->uri_schemes);
  registry->uri_schemes = NULL;
  g_strfreev (registry->mime_types);
  registry->mime_types = NULL;

  /* get a list of all active thumbnailers */
  thumbnailers = tumbler_registry_get_thumbnailers_internal (registry);

  tumbler_mutex_unlock (registry->mutex);

  /* abort if there are no thumbnailers */
  if (thumbnailers == NULL)
    return;

  /* clear visited flag of all thumbnailers */
  for (lp = thumbnailers; lp != NULL; lp = lp->next)
    g_object_set_qdata (lp->data, tumbler_registry_visited_quark, NULL);

  /* create a hash table to collect unique URI scheme / MIME type pairs */
  unique_pairs = g_hash_table_new_full (g_str_hash, g_str_equal,
                                        (GDestroyNotify) g_free,
                                        (GDestroyNotify) free_pair);

  /* prepare array */
  used_strings = g_ptr_array_new_full (150, g_free);

  /* iterate over all of them */
  for (lp = thumbnailers; lp != NULL; lp = lp->next)
    {
      if (g_object_get_qdata (lp->data, tumbler_registry_visited_quark) != NULL)
        continue;

      /* determine the MIME types & URI schemes supported by the current thumbnailer */
      mime_types = tumbler_thumbnailer_get_mime_types (lp->data);
      uri_schemes = tumbler_thumbnailer_get_uri_schemes (lp->data);

      /* insert all MIME types & URI schemes into the hash table */
      for (n = 0;
           mime_types != NULL && uri_schemes != NULL && mime_types[n] != NULL;
           ++n)
        {
          /* remember the MIME type so that we can later reuse it without copying */
          g_ptr_array_add (used_strings, mime_types[n]);

          for (u = 0; uri_schemes[u] != NULL; ++u)
            {
              /* remember the URI scheme for this pair so that we can later reuse it
               * without copying. Only remember it once (n==0) to avoid segmentation
               * faults when freeing the list */
              if (n == 0)
                g_ptr_array_add (used_strings, uri_schemes[u]);

              /* allocate a pair with the current URI scheme and MIME type */
              pair = g_slice_alloc (2 * sizeof (const gchar *));

              /* we can now reuse the strings */
              pair[0] = uri_schemes[u];
              pair[1] = mime_types[n];

              /* combine the two to a unique pair identifier */
              pair_string = g_strdup_printf ("%s-%s", pair[0], pair[1]);

              /* remember the pair in the hash table */
              g_hash_table_insert (unique_pairs, pair_string, pair);
            }
        }

      /* free MIME types & URI schemes array. Their contents are stored in
       * used_strings and are freed later */
      g_free (mime_types);
      g_free (uri_schemes);

      /* mark the thumbnailer as visited so we don't generate its
       * MIME type & URI scheme pairs multiple times */
      g_object_set_qdata (lp->data, tumbler_registry_visited_quark,
                          GUINT_TO_POINTER (1));
    }

  /* relase the thumbnailer list */
  g_list_free_full (thumbnailers, g_object_unref);

  n = g_hash_table_size (unique_pairs);

  tumbler_mutex_lock (registry->mutex);

  /* allocate a string array for the URI scheme / MIME type pairs */
  registry->uri_schemes = g_new0 (gchar *, n+1);
  registry->mime_types = g_new0 (gchar *, n+1);

  /* insert all unique URI scheme / MIME type pairs into string arrays */
  n = 0;
  g_hash_table_iter_init (&iter, unique_pairs);
  while (g_hash_table_iter_next (&iter, NULL, (gpointer) &pair))
    {
      /* fill the cache arrays with copied values */
      registry->uri_schemes[n] = g_strdup (pair[0]);
      registry->mime_types[n] = g_strdup (pair[1]);

      ++n;
    }

  /* NULL-terminate the arrays */
  registry->uri_schemes[n] = NULL;
  registry->mime_types[n] = NULL;

  tumbler_mutex_unlock (registry->mutex);

  /* destroy the hash table we used */
  g_hash_table_unref (unique_pairs);

  /* free all strings we used but haven't freed yet */
  g_ptr_array_free (used_strings, TRUE);
}



void
tumbler_registry_get_supported (TumblerRegistry     *registry,
                                const gchar *const **uri_schemes,
                                const gchar *const **mime_types)
{
  g_return_if_fail (TUMBLER_IS_REGISTRY (registry));

  tumbler_mutex_lock (registry->mutex);

  if (uri_schemes != NULL)
    *uri_schemes = (const gchar *const *)registry->uri_schemes;

  if (mime_types != NULL)
    *mime_types = (const gchar *const *)registry->mime_types;

  tumbler_mutex_unlock (registry->mutex);
}



TumblerThumbnailer *
tumbler_registry_get_preferred (TumblerRegistry *registry,
                                const gchar     *hash_key)
{
  TumblerThumbnailer *thumbnailer = NULL;

  g_return_val_if_fail (TUMBLER_IS_REGISTRY (registry), NULL);
  g_return_val_if_fail (hash_key != NULL && *hash_key != '\0', NULL);

  tumbler_mutex_lock (registry->mutex);
  thumbnailer = g_hash_table_lookup (registry->preferred_thumbnailers, hash_key);
  tumbler_mutex_unlock (registry->mutex);

  return thumbnailer != NULL ? g_object_ref (thumbnailer) : NULL;
}



void
tumbler_registry_set_preferred (TumblerRegistry    *registry,
                                const gchar        *hash_key,
                                TumblerThumbnailer *thumbnailer)
{
  g_return_if_fail (TUMBLER_IS_REGISTRY (registry));
  g_return_if_fail (hash_key != NULL && *hash_key != '\0');
  g_return_if_fail (thumbnailer == NULL || TUMBLER_IS_THUMBNAILER (thumbnailer));

  tumbler_mutex_lock (registry->mutex);

  if (thumbnailer == NULL)
    {
      g_hash_table_remove (registry->preferred_thumbnailers, hash_key);
    }
  else
    {
      g_hash_table_insert (registry->preferred_thumbnailers,
                           g_strdup (hash_key), g_object_ref (thumbnailer));
    }

  tumbler_mutex_unlock (registry->mutex);
}