Raised This Month: $12 Target: $400
 3% 

Solved Should I CloseHandle(plugin) ???


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-24-2016 , 00:39   Should I CloseHandle(plugin) ???
Reply With Quote #1

The below loops through plugins using the plugin iterator.

Code:
public void _Dynamic_HandleUsage()
{
	// Loop plugins
	Handle iterator = GetPluginIterator();
	Handle plugin;
	while (MorePlugins(iterator))
	{
		plugin = ReadPlugin(iterator);
	}
	CloseHandle(iterator);
}
Will this leak as I need to call CloseHandle(plugin); ?
__________________

Last edited by Neuro Toxin; 11-24-2016 at 03:31.
Neuro Toxin is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 11-24-2016 , 02:55   Re: Should I CloseHandle(plugin) ???
Reply With Quote #2

Yes.
https://sm.alliedmods.net/new-api/so...PluginIterator
__________________
hleV is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-24-2016 , 02:57   Re: Should I CloseHandle(plugin) ???
Reply With Quote #3

I already close the iterator handle.

The question is do i need to close the plugin handles.
__________________
Neuro Toxin is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-24-2016 , 03:07   Re: Should I CloseHandle(plugin) ???
Reply With Quote #4

You shouldn't need to do this. I think closing that handle may actually cause the plugin to screw up? Imma test it out real fast.

EDIT: Nevermind. Plugin handles are unclosable.

https://wiki.alliedmods.net/Handles_...pting)#Plugins
__________________

Last edited by ddhoward; 11-24-2016 at 03:10.
ddhoward is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-24-2016 , 03:07   Re: Should I CloseHandle(plugin) ???
Reply With Quote #5

Thats what i thought. Just afk atm so cant test
__________________
Neuro Toxin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-24-2016 , 03:08   Re: Should I CloseHandle(plugin) ???
Reply With Quote #6

You could always check and see if you get an error about not having permissions to close said handles.

I'm guessing you don't need to close them as they're likely owned by Core, same as CVar Handles.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 11-24-2016 , 03:15   Re: Should I CloseHandle(plugin) ???
Reply With Quote #7

I edited my previous post with my findings, before I saw that people had replied.

Plugin handles are owned by Core, and cannot be closed or cloned.
__________________
ddhoward is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 11-24-2016 , 03:31   Re: Should I CloseHandle(plugin) ???
Reply With Quote #8

Sweet. Thanks everyone
__________________
Neuro Toxin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode