From: Sam Thursfield Date: Wed, 6 Jul 2011 16:35:38 +0000 (+0100) Subject: client lib: release RPC binding on DLL unload X-Git-Tag: 0.7.1~203 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=adc806ad7c645657b56484ef12b254c3eff065c0;p=moonshot-ui.git client lib: release RPC binding on DLL unload --- diff --git a/libmoonshot/libmoonshot-msrpc.c b/libmoonshot/libmoonshot-msrpc.c index bfea62d..ad67f5c 100644 --- a/libmoonshot/libmoonshot-msrpc.c +++ b/libmoonshot/libmoonshot-msrpc.c @@ -371,3 +371,21 @@ int moonshot_get_default_identity (char **nai_out, return TRUE; }; + +BOOL WINAPI DllMain (HINSTANCE hinst, + DWORD reason, + void *reserved) +{ + if (reason == DLL_PROCESS_DETACH) { + /* Process exiting/DLL being unloaded. This is a good + * opportunity to free the RPC binding. + * + * FIXME: we can't use the msrpc-mingw routine for this in case + * it was already unloaded. I'd love to work out how to link + * that library statically into libmoonshot-0.dll. + */ + RpcBindingFree (&moonshot_binding_handle); + } + + return TRUE; +}