mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-22 10:12:20 +00:00
Исправлен баг с крашем сервера при повторном запуске ресурса
This commit is contained in:
parent
b19787ef76
commit
96734fe4c5
@ -34,17 +34,26 @@ CResource::CResource( lua_State *pLuaVM, string sName )
|
||||
|
||||
CResource::~CResource( void )
|
||||
{
|
||||
if( this->m_pMonoGCHandle )
|
||||
{
|
||||
mono_gchandle_free( this->m_pMonoGCHandle );
|
||||
}
|
||||
mono_domain_set( mono_get_root_domain(), false );
|
||||
|
||||
if( this->m_pMonoDomain )
|
||||
{
|
||||
mono_domain_unload( this->m_pMonoDomain );
|
||||
}
|
||||
|
||||
mono_gc_collect( mono_gc_max_generation() );
|
||||
|
||||
g_pResourceManager->RemoveFromList( this );
|
||||
|
||||
this->m_pMonoAssembly = NULL;
|
||||
this->m_pMonoAssemblyLib = NULL;
|
||||
this->m_pMonoGCHandle = NULL;
|
||||
this->m_pMonoDomain = NULL;
|
||||
this->m_pMonoImage = NULL;
|
||||
this->m_pMonoImageLib = NULL;
|
||||
this->m_pMonoClass = NULL;
|
||||
|
||||
this->m_pLuaVM = NULL;
|
||||
}
|
||||
|
||||
bool CResource::Init( void )
|
||||
@ -88,7 +97,7 @@ bool CResource::Init( void )
|
||||
|
||||
MonoObject *pMonoObject = mono_object_new( this->m_pMonoDomain, this->m_pMonoClass );
|
||||
|
||||
this->m_pMonoGCHandle = mono_gchandle_new( pMonoObject, true );
|
||||
mono_gchandle_new( pMonoObject, false );
|
||||
|
||||
mono_runtime_object_init( pMonoObject );
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
// mono_config_parse( NULL );
|
||||
|
||||
mono_debug_init( MONO_DEBUG_FORMAT_MONO );
|
||||
// mono_debug_init( MONO_DEBUG_FORMAT_MONO );
|
||||
|
||||
this->m_pMonoDomain = mono_jit_init_version( "Mono Root", "v4.0.30319" );
|
||||
|
||||
|
@ -46,6 +46,8 @@ extern "C"
|
||||
#include <mono/metadata/mono-debug.h>
|
||||
#include <mono/metadata/debug-helpers.h>
|
||||
#include <mono/metadata/environment.h>
|
||||
#include <mono/metadata/threads.h>
|
||||
#include <mono/metadata/mono-gc.h>
|
||||
|
||||
#include "include/ILuaModuleManager.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user