Got deadlock when i run my multiThread FTP application
-
Hi, I wrote some multiThread application that upload some file to FTP server. When i run 10 threads all work fine - but when i run 50 thread i have deadlock. I attached my code - this is the Connection method that each thread calls My code ...
bool FTPConnection::UploadInfo(CString MachineIpAddress, CString FileToDownload)
{
try
{
CMyInternetSession InternetSession;
CFtpConnection* ftpConnection = InternetSession.GetFtpConnection(MachineIpAddress, "admin", "admin");if( !ftpConnection->SetCurrentDirectory("/SomeFtpFoled")) { int E = GetLastError(); return false; } if(!ftpConnection->PutFile(FileToDownload, FileToDownload)) { int E = GetLastError(); return false; } return true; } catch (CException\* e) { return false; }
}
-
Hi, I wrote some multiThread application that upload some file to FTP server. When i run 10 threads all work fine - but when i run 50 thread i have deadlock. I attached my code - this is the Connection method that each thread calls My code ...
bool FTPConnection::UploadInfo(CString MachineIpAddress, CString FileToDownload)
{
try
{
CMyInternetSession InternetSession;
CFtpConnection* ftpConnection = InternetSession.GetFtpConnection(MachineIpAddress, "admin", "admin");if( !ftpConnection->SetCurrentDirectory("/SomeFtpFoled")) { int E = GetLastError(); return false; } if(!ftpConnection->PutFile(FileToDownload, FileToDownload)) { int E = GetLastError(); return false; } return true; } catch (CException\* e) { return false; }
}
-
Are you syncronizing threads. If there is a problem of Syncronization of threads then try using Mutex, critical section etc. try to syncronize the threads.
The thread are synchronize. I don't think that this is the synchronize problem because each thread is running ok. But - when i press on pause button - i see that some thread(s) are still waiting on the line "GetFtpConnection" and other thread(s) are still waiting on "PutFile". So i think that the synchronize of the thread is ok - and maybe i have some communication problem.
-
Hi, I wrote some multiThread application that upload some file to FTP server. When i run 10 threads all work fine - but when i run 50 thread i have deadlock. I attached my code - this is the Connection method that each thread calls My code ...
bool FTPConnection::UploadInfo(CString MachineIpAddress, CString FileToDownload)
{
try
{
CMyInternetSession InternetSession;
CFtpConnection* ftpConnection = InternetSession.GetFtpConnection(MachineIpAddress, "admin", "admin");if( !ftpConnection->SetCurrentDirectory("/SomeFtpFoled")) { int E = GetLastError(); return false; } if(!ftpConnection->PutFile(FileToDownload, FileToDownload)) { int E = GetLastError(); return false; } return true; } catch (CException\* e) { return false; }
}
I don't think that the scenario you're talking about is 'dead lock'. You are calling the synchronous calls like PutFile which returns only when the task gets completed or failed. Try out with opening the file using OpenFile and Write functions. You'll get closer control over the code and thread.
-Malli...! :rose:****
-
I don't think that the scenario you're talking about is 'dead lock'. You are calling the synchronous calls like PutFile which returns only when the task gets completed or failed. Try out with opening the file using OpenFile and Write functions. You'll get closer control over the code and thread.
-Malli...! :rose:****
-
The file are very small ( 2-3 Kb ) so i don't see any problem with waiting until the file will be done.
-
Hi, I wrote some multiThread application that upload some file to FTP server. When i run 10 threads all work fine - but when i run 50 thread i have deadlock. I attached my code - this is the Connection method that each thread calls My code ...
bool FTPConnection::UploadInfo(CString MachineIpAddress, CString FileToDownload)
{
try
{
CMyInternetSession InternetSession;
CFtpConnection* ftpConnection = InternetSession.GetFtpConnection(MachineIpAddress, "admin", "admin");if( !ftpConnection->SetCurrentDirectory("/SomeFtpFoled")) { int E = GetLastError(); return false; } if(!ftpConnection->PutFile(FileToDownload, FileToDownload)) { int E = GetLastError(); return false; } return true; } catch (CException\* e) { return false; }
}
On a side note, MFC exceptions should be deleted when caught with
catch
(e->Delete()
).Steve