Skip to content

Commit 8c6ae3f

Browse files
bjoriajdavis
authored andcommitted
CDRIVER-1504 Don't warn when intentionally disabled
1 parent 709a7dc commit 8c6ae3f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/mongoc/mongoc-counters.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ mongoc_counters_alloc (size_t size)
163163
int fd;
164164

165165
if (!mongoc_counters_use_shm ()) {
166-
goto use_malloc;
166+
goto skip_shm;
167167
}
168168

169169
pid = getpid ();
170170
bson_snprintf (name, sizeof name, "/mongoc-%u", pid);
171171

172172
if (-1 == (fd = shm_open (name, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR))) {
173-
goto use_malloc;
173+
goto fail_noclean;
174174
}
175175

176176
/*
@@ -180,25 +180,27 @@ mongoc_counters_alloc (size_t size)
180180
* do write() of zeroes to initialize the shared memory area.
181181
*/
182182
if (-1 == ftruncate (fd, size)) {
183-
goto failure;
183+
goto fail_cleanup;
184184
}
185185

186186
mem = mmap (NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
187187
if (mem == MAP_FAILED) {
188-
goto failure;
188+
goto fail_cleanup;
189189
}
190190

191191
close (fd);
192192
memset (mem, 0, size);
193193

194194
return mem;
195195

196-
failure:
196+
fail_cleanup:
197197
shm_unlink (name);
198198
close (fd);
199199

200-
use_malloc:
200+
fail_noclean:
201201
MONGOC_WARNING("Falling back to malloc for counters.");
202+
203+
skip_shm:
202204
#endif
203205

204206
gCounterFallback = (void *)bson_malloc0 (size);

0 commit comments

Comments
 (0)