1473: TerminateThreads does not finish cleanly [#9229]

Beta Testing for Windows Products and plugins

Moderator: Gurus

markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

1473: TerminateThreads does not finish cleanly [#9229]

Post 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.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
Ludek
Posts: 5089
Joined: Fri Mar 09, 2007 9:00 am

Re: 1473: TerminateThreads does not finish cleanly

Post 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.
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: 1473: TerminateThreads does not finish cleanly

Post by markstuartwalker »

When might I get visibility of this release for testing?
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: 1473: TerminateThreads does not finish cleanly

Post 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.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
rusty
Posts: 8843
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: 1473: TerminateThreads does not finish cleanly

Post by rusty »

Hi Mark,

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

Thanks.

-Rusty
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: 1473: TerminateThreads does not finish cleanly

Post 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.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
Ludek
Posts: 5089
Joined: Fri Mar 09, 2007 9:00 am

Re: 1473: TerminateThreads does not finish cleanly

Post 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.
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

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

Post 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
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
Ludek
Posts: 5089
Joined: Fri Mar 09, 2007 9:00 am

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

Post 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.
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

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

Post 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.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

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

Post 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.
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
Post Reply