Go Back   FlashFXP Forums > >

Programming Need help with C/C++/Delphi? Ask here and make us all laugh.

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 10-17-2003, 10:51 PM   #1
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default bad ONLINEDATA usage ?

What's wrong with this code ?
It appears to work correctly, until you try to run multiple threads that does that... Then, it makes io (.14 and probably earlier) crash (probably when 2 threads do that at the exact same time).

I know it's this code that makes it crash cause if i comment the sendmessage, it doesn't crash anymore.

Code:
int iPos = 0, nPos = 0, Users = 0;
while (nPos != -1 && Users < 1000 ) {
	// Initial setup for DC_GET_ONLINEDATA
	lpMessage->dwIdentifier	= DC_GET_ONLINEDATA;
	LPDC_ONLINEDATA pOnlineData = (LPDC_ONLINEDATA)lpMessage->lpContext;
	pOnlineData->iOffset = nPos;
	pOnlineData->dwSharedMemorySize = sizeof(DC_MESSAGE) + sizeof(DC_ONLINEDATA) + (_MAX_PATH + 1) * 2;

	// Send Message
	dwReturn = SendMessage(hIoFTPD, WM_SHMEM, NULL, (LPARAM)hMemory);
	if (!dwReturn) {
		// Wait until processed (5 secs)
		if (WaitForSingleObject(hEvent, 5000) == WAIT_TIMEOUT) break;

		nPos = pOnlineData->iOffset;
		if (iPos>=nPos || nPos == 1024)
			break;

		Users++;
		iPos = nPos;
	}
}
Mouton is offline  
Old 10-18-2003, 05:29 AM   #2
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Can you create me some simple binary that does it when executed from command line.. (might be that there's something wrong with the datacopy command queueing.. as i've only allowed 2worker threads to execute datacopy commands concurrently [special queue for those])
darkone is offline  
Old 10-18-2003, 05:31 AM   #3
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Also, use asynchronous postmessage instead of sendmessage.. it's somewhat faster, and since you don't need to worry about wheter message gets through or not - it's optimal for the purpose.
darkone is offline  
Old 10-18-2003, 05:50 AM   #4
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Also.. I'm not sure wheter 5secs is enough or not
darkone is offline  
Old 10-18-2003, 08:00 AM   #5
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default

still crash with PostMessage and 10s wait...

I'll get u a little .exe
Mouton is offline  
Old 10-18-2003, 08:13 AM   #6
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Create me that test app, and i'll give it a spin under debugger... propably something really simple that i've missed out (also check wheter your waitforsingleevent returns WAIT_TIMEOUT.. you never know )
darkone is offline  
Old 10-18-2003, 08:45 AM   #7
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default

[Pre]
stor = EXEC "D:\Visual Studio Projects\testDC\Debug\testDC.exe"

It crash io when i use it there. When i run it from command-line, i can spawn 10 instances at the same time, it still works ok.

But if i put it in Pre Stor, and i simulate a race of 8 users (30x5mb files), it crash io.
Attached Files
File Type: zip testdc.zip (34.2 KB, 9 views)
Mouton is offline  
Old 10-18-2003, 09:41 AM   #8
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default

Ok.. found it, if all threads are executing scripts that require datacopy - datacopy will time-out, and once you exit your process - crash will occur, as you have already freed the memory area that datacopy tries to process. Threading is fun, isn't it?

Sounds like I have to do minor change in datacopy structure; DC_MESSAGE + add specific datacopy threads :/ Expect to see fix sometime tomorrow
darkone is offline  
Old 10-18-2003, 11:32 AM   #9
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default

thx very much
Mouton is offline  
Closed Thread

Tags
crash, dwreturn, ipos, npos, threads

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Site to site question, wont connect Xbox4144 General Discussion 3 01-09-2005 10:38 AM


All times are GMT -5. The time now is 10:47 AM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)