Page 1 of 1

1473: TerminateThreads does not finish cleanly [#9229]

Posted: Thu Feb 16, 2012 10:16 am
by markstuartwalker
This is an old issue from http://www.mediamonkey.com/forum/viewto ... ds#p317810

I thought that I'd covered this off already but recent testing in another area I revealed that it does terminate but it leaves the current message on the status bar.

For example, if I call this from within DEVICE_GetFlag via the dflFullSynchStart constant it leaves the message "Synchronising d_itunes4.dll on xxxxx: (preparing list of files)". Terminating the thread ought to clear the message too.

In Delphi I can see a repeating message "Waiting for SyncroniseDevice thread to terminate" message. Further, if MM is closed in this state it says that there are background tasks running.

... or perhaps we ought to terminate device synchronisation more cleanly than just killing the tasks.

Re: 1473: TerminateThreads does not finish cleanly

Posted: Thu Mar 22, 2012 11:11 am
by Ludek
You seem to be true that MediaMonkey should check more often whether the thread is about to be terminated and to terminate it ASAP.

I will fix it.

Re: 1473: TerminateThreads does not finish cleanly

Posted: Thu Mar 22, 2012 11:18 am
by Ludek

Re: 1473: TerminateThreads does not finish cleanly

Posted: Mon Mar 26, 2012 2:51 am
by markstuartwalker
When might I get visibility of this release for testing?

Re: 1473: TerminateThreads does not finish cleanly

Posted: Fri Apr 13, 2012 10:16 am
by markstuartwalker
I've checked build 4.0.5.1481. I have a slightly modified test case that doesn't work.

* Sync 20 tracks.
* Change the auto sync list so only 10 tracks will remain.
* Sync and see the "10/20 of the tracks are to be deleted. Continue to delete?" message appearing.
* Select "No"

This causes the TerminateThreads function to be called from within the DEVICE_DeleteFiles() function. Result is that the "Removing old content" message remains forever.

When finally MM is manually closed it says that there are background tasks running.

Re: 1473: TerminateThreads does not finish cleanly

Posted: Fri Apr 27, 2012 8:52 am
by rusty
Hi Mark,

Can you confirm that this is working for you as expected in build 1484?

Thanks.

-Rusty

Re: 1473: TerminateThreads does not finish cleanly

Posted: Fri May 04, 2012 1:57 am
by markstuartwalker
Sorry for the delay. I've tested with 1486. The problem is still there.

The sync message remains on screen. When closing MM it says there are background tasks. Need to forcibly close using Task Manager.

Re: 1473: TerminateThreads does not finish cleanly

Posted: Mon May 07, 2012 5:47 pm
by Ludek
markstuartwalker wrote:Sorry for the delay. I've tested with 1486. The problem is still there.

The sync message remains on screen. When closing MM it says there are background tasks. Need to forcibly close using Task Manager.

Mark, strange, I can no longer replicate anything like this after the fix.

Maybe there is a misunderstanding, do we both think the "Delete from device" dialog saying:
"The following X items on youre device ...... Do you want to remove them from the device?" and there are buttons
[Continue] [Cancel]

you click [Cancel] and are you saying that the problem described by you appears?

It shouldn't get into DEVICE_DeleteFiles if you clicked [Cancel], so you clicked [Continue]?

And even if I click [Continue] and put TerminateThreads() into the DEVICE_DeleteFiles() I can no longer reproduce the issue in 1486.
Please re-test or send me your plugin to reproduce.

Re: 1473: TerminateThreads does not finish cleanly [#9229]

Posted: Tue May 08, 2012 11:40 am
by markstuartwalker
Misunderstanding. My plugin has an addition check for more than 5% of the files being deleted. It's dialogue is what I refer to and not the mm one.

Plugin can be downloaded from the mm site

Re: 1473: TerminateThreads does not finish cleanly [#9229]

Posted: Tue May 08, 2012 5:58 pm
by Ludek
markstuartwalker wrote:Misunderstanding. My plugin has an addition check for more than 5% of the files being deleted. It's dialogue is what I refer to and not the mm one.

Plugin can be downloaded from the mm site
Aha then, that was really misunderstanding.

The deadlock here was caused by the fact that you called TSDBDevice.TerminateThreads() function from the thread that was about to terminate, and there was waiting for the termination in the TSDBDevice.TerminateThreads()

I removed the waiting from the TSDBDevice.TerminateThreads() function, will be fixed in build 1489.

Re: 1473: TerminateThreads does not finish cleanly [#9229]

Posted: Thu May 10, 2012 11:35 am
by markstuartwalker
Ok. ALL of my code runs under the sync so I thought that was pretty obvious. I described this as a suicide call.

I look forward to the next release.

Re: 1473: TerminateThreads does not finish cleanly [#9229]

Posted: Sat May 12, 2012 3:26 am
by markstuartwalker
Tested MM 4.0.5.1489 and this seems to fix the problems. :-) The sync message is removed immediately, the sync can be re-attempted and if MM closes it no longer reports that there are background running tasks.

Thank you.