From a9633313ec8e578c805cd53b37ba3360d83157bc Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 15 Aug 2017 21:59:55 -0700 Subject: Provide versions of mutex, condvar, and aio init that never fail. If the underlying platform fails (FreeBSD is the only one I'm aware of that does this!), we use a global lock or condition variable instead. This means that our lock initializers never ever fail. Probably we could eliminate most of this for Linux and Darwin, since on those platforms, mutex and condvar initialization reasonably never fails. Initial benchmarks show little difference either way -- so we can revisit (optimize) later. This removes a lot of otherwise untested code in error cases and so forth, improving coverage and resilience in the face of allocation failures. Platforms other than POSIX should follow a similar pattern if they need this. (VxWorks, I'm thinking of you.) Most sane platforms won't have an issue here, since normally these initializations do not need to allocate memory. (Reportedly, even FreeBSD has plans to "fix" this in libthr2.) While here, some bugs were fixed in initialization & teardown. The fallback code is properly tested with dedicated test cases. --- src/core/init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/core/init.c') diff --git a/src/core/init.c b/src/core/init.c index 24a7b118..4025c0f4 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -1,5 +1,5 @@ // -// Copyright 2016 Garrett D'Amore +// Copyright 2017 Garrett D'Amore // Copyright 2017 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -39,8 +39,6 @@ nni_init(void) void nni_fini(void) { - // XXX: We should make sure that underlying sockets and - // file descriptors are closed. Details TBD. nni_tran_sys_fini(); nni_pipe_sys_fini(); nni_ep_sys_fini(); -- cgit v1.2.3-70-g09d2