@@ -18,7 +18,7 @@ struct tmp_objdir {
18
18
19
19
/*
20
20
* Allow only one tmp_objdir at a time in a running process, which simplifies
21
- * our signal/ atexit cleanup routines. It's doubtful callers will ever need
21
+ * our atexit cleanup routines. It's doubtful callers will ever need
22
22
* more than one, and we can expand later if so. You can have many such
23
23
* tmp_objdirs simultaneously in many processes, of course.
24
24
*/
@@ -31,7 +31,7 @@ static void tmp_objdir_free(struct tmp_objdir *t)
31
31
free (t );
32
32
}
33
33
34
- static int tmp_objdir_destroy_1 (struct tmp_objdir * t , int on_signal )
34
+ int tmp_objdir_destroy (struct tmp_objdir * t )
35
35
{
36
36
int err ;
37
37
@@ -41,44 +41,21 @@ static int tmp_objdir_destroy_1(struct tmp_objdir *t, int on_signal)
41
41
if (t == the_tmp_objdir )
42
42
the_tmp_objdir = NULL ;
43
43
44
- if (! on_signal && t -> prev_odb )
44
+ if (t -> prev_odb )
45
45
restore_primary_odb (t -> prev_odb , t -> path .buf );
46
46
47
- /*
48
- * This may use malloc via strbuf_grow(), but we should
49
- * have pre-grown t->path sufficiently so that this
50
- * doesn't happen in practice.
51
- */
52
47
err = remove_dir_recursively (& t -> path , 0 );
53
48
54
- /*
55
- * When we are cleaning up due to a signal, we won't bother
56
- * freeing memory; it may cause a deadlock if the signal
57
- * arrived while libc's allocator lock is held.
58
- */
59
- if (!on_signal )
60
- tmp_objdir_free (t );
49
+ tmp_objdir_free (t );
61
50
62
51
return err ;
63
52
}
64
53
65
- int tmp_objdir_destroy (struct tmp_objdir * t )
66
- {
67
- return tmp_objdir_destroy_1 (t , 0 );
68
- }
69
-
70
54
static void remove_tmp_objdir (void )
71
55
{
72
56
tmp_objdir_destroy (the_tmp_objdir );
73
57
}
74
58
75
- static void remove_tmp_objdir_on_signal (int signo )
76
- {
77
- tmp_objdir_destroy_1 (the_tmp_objdir , 1 );
78
- sigchain_pop (signo );
79
- raise (signo );
80
- }
81
-
82
59
void tmp_objdir_discard_objects (struct tmp_objdir * t )
83
60
{
84
61
remove_dir_recursively (& t -> path , REMOVE_DIR_KEEP_TOPLEVEL );
@@ -152,14 +129,6 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)
152
129
*/
153
130
strbuf_addf (& t -> path , "%s/tmp_objdir-%s-XXXXXX" , get_object_directory (), prefix );
154
131
155
- /*
156
- * Grow the strbuf beyond any filename we expect to be placed in it.
157
- * If tmp_objdir_destroy() is called by a signal handler, then
158
- * we should be able to use the strbuf to remove files without
159
- * having to call malloc.
160
- */
161
- strbuf_grow (& t -> path , 1024 );
162
-
163
132
if (!mkdtemp (t -> path .buf )) {
164
133
/* free, not destroy, as we never touched the filesystem */
165
134
tmp_objdir_free (t );
@@ -169,7 +138,6 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix)
169
138
the_tmp_objdir = t ;
170
139
if (!installed_handlers ) {
171
140
atexit (remove_tmp_objdir );
172
- sigchain_push_common (remove_tmp_objdir_on_signal );
173
141
installed_handlers ++ ;
174
142
}
175
143
0 commit comments