fix: remove plugin directory handle without fail handles greater than the removed one. #2018

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

ulion commented Jan 3, 2013

currently, remove a handle will fail all other handles which greater than the removed one, this will happen when more than one plugindirectory script running within a overlapped time.
it's a obvious bug since the handle supposed not always be 0, there is possibility following example happens:

ui make a plugin dir listing request, which assigned handle 0:
plugin with handle 0 begin
json-rpc make another plugin dir listing request, which assigned handle 1:
plugin with handle 1 begin
plugin with handle 0 end, in the current code, the handle will be erased
plugin with handle 1 call function like setEndOfDirectory but handle 1 does not existed, the globalHandles vector size is 1 now the CPluginDirectory object with original handle 1 now on the handle 0 position, so the setEndOfDirectory call will failed, it's a mistake, this commit fix this problem.

btw, I'm writing addons, but have no machine to compile xbmc, so please test it first before merge to the main branch.

I suggest grabbing the first NULL handle in getNewHandle() as well (should one exist). That way you'll cleanup the first handles as they are done. I'd also lock in dirFromHandle() as otherwise it is likely to be called later without the lock.

I'd also add a comment to the block that's cleaning out the handles at the end of the vector so it's clear what the code is doing.

Looks good other than that - thanks!

Owner

ulion replied Jan 3, 2013

the first thought I also want to use the first NULL value handle, but I found always use greatest handle for the new one will let debug more easy, and there's nothing to lose in that condition but more debug friendly, so I choose this plan.
about the lock, you are right, I will try update this PR.

That's fine - update the PR with the fix (just squash the fix into this commit and force push to your repo) to the locking and I'll take another look before pulling it in.

Owner

ulion replied Jan 3, 2013

I didn't known the squash stuff before this, now I known how to co-work on the git. thank you!

Contributor

ulion commented Jan 3, 2013

thanks for reply, I had to close this pull req and using another one since this branch name is used by my previous request with a typo in the code, the issue still listing the old typo one since they share the same branch name.
I will reply your comment in the new issue

ulion closed this Jan 3, 2013

ulion deleted the ulion:plugin_dir_handle_fix branch Jan 3, 2013

Owner

MartijnKaijser commented Jan 3, 2013

next time you can just change your code and do a force push to your repo. saves opening a new PR

Contributor

ulion commented Jan 3, 2013

thanks the suggesting, now I know how to do next time.

Contributor

ulion commented Jan 3, 2013

and I still didn't figure out why pull 2019 not showed in the issue list. I already changed branch name but it's still only in the pull request list while not in the issue list.
any way, this issue and pull request was closed, please goto #2019 to continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment