summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2009-10-15 10:26:27 +0000
committerfcolin2009-10-15 10:26:27 +0000
commit473bf59297a9c8010fb35f505c872024ae3d259d (patch)
treeba296d860b9ecda9101b76f1eea4407daa997a38
parent3bd1423d9bd7374c2d39f9817e3a1caa836f86e6 (diff)
downloadivy-cplusplus-473bf59297a9c8010fb35f505c872024ae3d259d.zip
ivy-cplusplus-473bf59297a9c8010fb35f505c872024ae3d259d.tar.gz
ivy-cplusplus-473bf59297a9c8010fb35f505c872024ae3d259d.tar.bz2
ivy-cplusplus-473bf59297a9c8010fb35f505c872024ae3d259d.tar.xz
correction bug threaded IvyApplication
correction checkconnected self
-rw-r--r--Bus.sln6
-rw-r--r--Ivy/BufferedSocket.cxx3
-rw-r--r--Ivy/InstIvyDev/InstIvyDev.vdproj64
-rw-r--r--Ivy/Ivy.cxx43
-rw-r--r--Ivy/Ivy.vcproj3
-rw-r--r--Ivy/IvyApplication.cxx10
-rw-r--r--Ivy/IvyApplication.h3
-rw-r--r--Ivy/IvyBinding.cxx6
-rw-r--r--Ivy/IvyBinding.h8
-rw-r--r--Ivy/IvySynchroWnd.cxx24
-rw-r--r--Ivy/IvyWatcher.cxx8
-rw-r--r--Ivy/IvyWatcher.h3
-rw-r--r--Ivy/ThreadedSocket.cxx27
13 files changed, 128 insertions, 80 deletions
diff --git a/Bus.sln b/Bus.sln
index 4af1d87..cd52cd3 100644
--- a/Bus.sln
+++ b/Bus.sln
@@ -38,7 +38,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IvyTestReady", "IvyTestRead
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
- SccNumberOfProjects = 9
+ SccNumberOfProjects = 10
SccProjectName0 = \u0022$/Bus\u0022,\u0020ZOBAAAAA
SccLocalPath0 = .
SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe
@@ -75,6 +75,10 @@ Global
SccLocalPath8 = .
CanCheckoutShared = false
SccProjectFilePathRelativizedFromConnection8 = IvyThroughput\\
+ SccProjectUniqueName9 = IvyTestReady\\IvyTestReady.vcproj
+ SccLocalPath9 = .
+ CanCheckoutShared = false
+ SccProjectFilePathRelativizedFromConnection9 = IvyTestReady\\
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
diff --git a/Ivy/BufferedSocket.cxx b/Ivy/BufferedSocket.cxx
index fcf90c6..b91386f 100644
--- a/Ivy/BufferedSocket.cxx
+++ b/Ivy/BufferedSocket.cxx
@@ -24,6 +24,7 @@ CBufferedSocket::CBufferedSocket()
CBufferedSocket::~CBufferedSocket()
{
free( buffer );
+ DeleteCriticalSection( &m_CritSection );
}
void CBufferedSocket::Accept(CBufferedSocket& rConnectedSocket, SOCKADDR* lpSockAddr , int* lpSockAddrLen )
{
@@ -74,7 +75,7 @@ void CBufferedSocket::OnReceive(int nErrorCode)
current_ptr += nb;
ptr = buffer;
- while ((ptr_sep = (char*)memchr (ptr, separator, current_ptr - ptr )))
+ while ((ptr_sep = (char*)memchr (ptr, separator, current_ptr - ptr )) && m_hSocket != INVALID_SOCKET)
{
*ptr_sep = '\0';
//TRACE("message %s\n", ptr );
diff --git a/Ivy/InstIvyDev/InstIvyDev.vdproj b/Ivy/InstIvyDev/InstIvyDev.vdproj
index 7d9a8e5..93940ee 100644
--- a/Ivy/InstIvyDev/InstIvyDev.vdproj
+++ b/Ivy/InstIvyDev/InstIvyDev.vdproj
@@ -15,32 +15,32 @@
{
"Entry"
{
- "MsmKey" = "8:_1AF7586332934A1D8068AF6C422CC2DD"
- "OwnerKey" = "8:_E8DA4E6514774E88A3E16EC00C9A093D"
+ "MsmKey" = "8:_24147F7608474FDFA0356D15DB2541B9"
+ "OwnerKey" = "8:_29AD2F070A5C499F9F0A5F03831C0D16"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_32C90C9C8FC242AE9C65DA1C92DA2700"
- "OwnerKey" = "8:_UNDEFINED"
+ "MsmKey" = "8:_29AD2F070A5C499F9F0A5F03831C0D16"
+ "OwnerKey" = "8:_587183B52DD64752997FFA522BC57D0A"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_3B5C053C16CE42B2810E6471B5EBFDBD"
+ "MsmKey" = "8:_32C90C9C8FC242AE9C65DA1C92DA2700"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_587183B52DD64752997FFA522BC57D0A"
+ "MsmKey" = "8:_3B5C053C16CE42B2810E6471B5EBFDBD"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_6ACC064FA1FC418FAB2B122A5F09BAB0"
- "OwnerKey" = "8:_A83C290CFE914EFBBD8EBED57EFBE505"
+ "MsmKey" = "8:_587183B52DD64752997FFA522BC57D0A"
+ "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
@@ -51,32 +51,32 @@
}
"Entry"
{
- "MsmKey" = "8:_A83C290CFE914EFBBD8EBED57EFBE505"
- "OwnerKey" = "8:_587183B52DD64752997FFA522BC57D0A"
+ "MsmKey" = "8:_955B831839B448359371A8AFFD90D6FB"
+ "OwnerKey" = "8:_ABC604C5C6884BEC87F60BD6D1527949"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_B656C8E7B4C5444BB7CAA2BB82B22DEB"
- "OwnerKey" = "8:_UNDEFINED"
+ "MsmKey" = "8:_ABC604C5C6884BEC87F60BD6D1527949"
+ "OwnerKey" = "8:_32C90C9C8FC242AE9C65DA1C92DA2700"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_E8DA4E6514774E88A3E16EC00C9A093D"
- "OwnerKey" = "8:_32C90C9C8FC242AE9C65DA1C92DA2700"
+ "MsmKey" = "8:_ABC604C5C6884BEC87F60BD6D1527949"
+ "OwnerKey" = "8:_587183B52DD64752997FFA522BC57D0A"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_E8DA4E6514774E88A3E16EC00C9A093D"
- "OwnerKey" = "8:_587183B52DD64752997FFA522BC57D0A"
+ "MsmKey" = "8:_ABC604C5C6884BEC87F60BD6D1527949"
+ "OwnerKey" = "8:_3B5C053C16CE42B2810E6471B5EBFDBD"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
- "MsmKey" = "8:_E8DA4E6514774E88A3E16EC00C9A093D"
- "OwnerKey" = "8:_3B5C053C16CE42B2810E6471B5EBFDBD"
+ "MsmKey" = "8:_B656C8E7B4C5444BB7CAA2BB82B22DEB"
+ "OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
}
@@ -114,7 +114,7 @@
"DisplayName" = "8:Release"
"IsDebugOnly" = "11:FALSE"
"IsReleaseOnly" = "11:TRUE"
- "OutputFilename" = "8:Release\\InstIvyDev.msi"
+ "OutputFilename" = "8:Release\\InstallIvyDev.msi"
"PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648"
"CabType" = "3:1"
@@ -284,19 +284,19 @@
"Product"
{
"Name" = "8:Microsoft Visual Studio"
- "ProductName" = "8:InstIvyDev"
- "ProductCode" = "8:{3534F30C-6A33-4023-9256-1A889832F9A5}"
- "PackageCode" = "8:{7205FDA9-231D-4053-9135-0FCA66792070}"
+ "ProductName" = "8:InstallIvyDev"
+ "ProductCode" = "8:{3E9E0C6D-CF2A-4C67-986F-DB51AFE4BA90}"
+ "PackageCode" = "8:{7D6F8203-0803-4355-AB45-C85C2DEBAAD2}"
"UpgradeCode" = "8:{B61AA283-78E2-443D-A093-4D5D6C0B779A}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
- "ProductVersion" = "8:1.3.1"
+ "ProductVersion" = "8:1.4.1"
"Manufacturer" = "8:DTI/R&D"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:http://www.tls.cena.fr/products/ivy"
- "Title" = "8:InstIvyDev"
+ "Title" = "8:InstallIvyDev"
"Subject" = "8:Ivy"
"ARPCONTACT" = "8:DTI/R&D"
"Keywords" = "8:Ivy"
@@ -801,11 +801,11 @@
}
"MergeModule"
{
- "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_1AF7586332934A1D8068AF6C422CC2DD"
+ "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_24147F7608474FDFA0356D15DB2541B9"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
- "SourcePath" = "8:microsoft_vc90_crt_x86_x64.msm"
+ "SourcePath" = "8:microsoft_vc90_mfc_x86.msm"
"Properties"
{
}
@@ -815,11 +815,11 @@
"Feature" = "8:"
"IsolateTo" = "8:"
}
- "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_6ACC064FA1FC418FAB2B122A5F09BAB0"
+ "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_29AD2F070A5C499F9F0A5F03831C0D16"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
- "SourcePath" = "8:microsoft_vc90_mfc_x86_x64.msm"
+ "SourcePath" = "8:policy_9_0_Microsoft_VC90_MFC_x86.msm"
"Properties"
{
}
@@ -829,11 +829,11 @@
"Feature" = "8:"
"IsolateTo" = "8:"
}
- "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_A83C290CFE914EFBBD8EBED57EFBE505"
+ "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_955B831839B448359371A8AFFD90D6FB"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
- "SourcePath" = "8:policy_9_0_Microsoft_VC90_MFC_x86_x64.msm"
+ "SourcePath" = "8:microsoft_vc90_crt_x86.msm"
"Properties"
{
}
@@ -843,11 +843,11 @@
"Feature" = "8:"
"IsolateTo" = "8:"
}
- "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_E8DA4E6514774E88A3E16EC00C9A093D"
+ "{CEE29DC0-9FBA-4B99-8D47-5BC643D9B626}:_ABC604C5C6884BEC87F60BD6D1527949"
{
"UseDynamicProperties" = "11:TRUE"
"IsDependency" = "11:TRUE"
- "SourcePath" = "8:policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"
+ "SourcePath" = "8:policy_9_0_Microsoft_VC90_CRT_x86.msm"
"Properties"
{
}
diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx
index fa1021d..fe05e7d 100644
--- a/Ivy/Ivy.cxx
+++ b/Ivy/Ivy.cxx
@@ -86,7 +86,7 @@ const char *Ivy::GenApplicationUniqueIdentifier()
unsigned long curtime;
curtime = GetTickCount();
srand( curtime );
- sprintf(appid,"%d:%lu:%d",rand(),curtime,applicationPort);
+ sprintf_s(appid,sizeof(appid),"%d:%lu:%d",rand(),curtime,applicationPort);
return appid;
}
@@ -133,20 +133,30 @@ const char * Ivy::GetDomain(const char *domainlist)
void Ivy::start(const char *domain)
{
+ if ( watcher->IsRunning() )
+ {
+ Ivy::stop();
+ }
watcher->start(domain);
}
void Ivy::stop()
{
watcher->stop();
+ EnterCriticalSection( &m_application_cs );
IvyApplicationList::iterator iter;
- for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
+ IvyApplicationList copy_applications;
+ copy_applications = applications;
+ applications.clear();
+ LeaveCriticalSection( &m_application_cs );
+
+ for ( iter = copy_applications.begin() ; iter != copy_applications.end() ; ++iter )
{
IvyApplication *app = *iter;
app->Close();
delete app;
}
- applications.clear();
+
}
int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb)
{
@@ -260,13 +270,14 @@ void Ivy::AddApplication(IvyApplication *app)
}
void Ivy::RemoveApplication(IvyApplication * app)
{
- /// OLD NOT called because of deallocation PB
+ /// OLD NOT called because of deallocation PB
+ // when self application close !!
// the real remove is done at arrival of a new Application
// or at the bus Stop
TRACE( "Ivy::RemoveApplication %lu\n", app );
+ ASSERT( true );
if ( app )
{
-
EnterCriticalSection( &m_application_cs );
applications.remove( app );
LeaveCriticalSection( &m_application_cs );
@@ -408,24 +419,30 @@ void Ivy::SetFilter(int argc, const char **argv )
IvyApplication * Ivy::CheckConnected(IvyApplication * app)
{
+ IvyApplication *application = 0;
if (app->remoteService == 0) /* old application dont check */
- return 0;
+ return application;
/* check to see if app already connected */
+ EnterCriticalSection( &m_application_cs );
IvyApplicationList::iterator iter;
for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *application = *iter;
- if ( application != app && application->SameApplication(app))
- return application;
+ IvyApplication *other = *iter;
+ if ( other != app && other->SameApplication(app))
+ {
+ application = other;
+ break;
+ }
}
- return 0;
+ LeaveCriticalSection( &m_application_cs );
+ return application;
}
void Ivy::SubstituteInterval (const char *src, char *dst, size_t dst_len)
{
// pas de traitement couteux s'il n'y a rien à interpoler
if (strstr (src, "(?I") == NULL) {
- strcpy (dst,src);
+ strcpy_s (dst,dst_len,src);
return;
} else {
char *curPos;
@@ -443,7 +460,7 @@ void Ivy::SubstituteInterval (const char *src, char *dst, size_t dst_len)
dstPos += lenCp;
// extraction des paramètres de l'intervalle
- sscanf (itvPos, "(?I%d#%d%c", &min, &max, &withDecimal);
+ sscanf_s (itvPos, "(?I%d#%d%c", &min, &max, &withDecimal);
// printf ("DBG> substituteInterval min=%d max=%d withDecimal=%d\n",
// min, max, (withDecimal != 'i'));
@@ -456,7 +473,7 @@ void Ivy::SubstituteInterval (const char *src, char *dst, size_t dst_len)
curPos = strstr (curPos, ")");
curPos++;
}
- strncat (dstPos, curPos, dst_len-(dstPos-dst));
+ strncat_s (dstPos,dst_len-( dst-dstPos), curPos, dst_len-(dstPos-dst));
}
}
diff --git a/Ivy/Ivy.vcproj b/Ivy/Ivy.vcproj
index 386e29e..f547577 100644
--- a/Ivy/Ivy.vcproj
+++ b/Ivy/Ivy.vcproj
@@ -84,7 +84,6 @@
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories=""
- GenerateManifest="false"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
@@ -381,7 +380,7 @@
<References>
<ProjectReference
ReferencedProjectIdentifier="{D79FC143-498E-4342-B2C7-BDAD1B8D0E6B}"
- RelativePathToProject="..\..\pcre\pcre.vcproj"
+ RelativePathToProject="..\..\..\..\Users\fcolin\Documents\Projects Visual Studio\pcre\pcre.vcproj"
/>
</References>
<Files>
diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx
index 4b41bbe..ab0cd9e 100644
--- a/Ivy/IvyApplication.cxx
+++ b/Ivy/IvyApplication.cxx
@@ -50,6 +50,7 @@ IvyApplication::IvyApplication(Ivy * bus)
appname = "Unknown";
AppConnectedCallbackCalled = false;
readyToSend = 0;
+ regexp_in.clear();
InitializeCriticalSection(&m_SendReadySection );
}
@@ -128,7 +129,6 @@ void IvyApplication::OnReceive(char * line)
{
TRACE("Quitting bad format %s\n", line);
SendMsg(Error, Error, "bad format request expected 'type id ...'");
-// bus->RemoveApplication( this );
Close();
return;
}
@@ -141,9 +141,7 @@ void IvyApplication::OnReceive(char * line)
TRACE("Quitting %s\n", line);
#endif //IVY_DEBUG
-// bus->RemoveApplication( this );
OnClose(0);
- //Close();
break;
case Error:
@@ -185,7 +183,6 @@ void IvyApplication::OnReceive(char * line)
regexp_str_in.resize( id + 1 );
}*/
regexp_in[ id ] = exp;
- regexp_str_in[ id ] = arg;
#ifdef IVY_DEBUG
TRACE("Adding regexp[%d]='%s' size: %d\n",id,arg,regexp_in.size());
#endif //IVY_DEBUG
@@ -199,8 +196,7 @@ void IvyApplication::OnReceive(char * line)
if ( regexp_in[id] )
{
exp = regexp_in[ id ];
- bus->CallBindingRemoveCallback( this, id, regexp_str_in[id].c_str() );
-
+ bus->CallBindingRemoveCallback( this, id, exp->getExpression() );
delete exp;
regexp_in[ id ] = NULL;
}
@@ -234,7 +230,6 @@ void IvyApplication::OnReceive(char * line)
TRACE("Quitting already connected %s\n", appname.c_str());
target->SendMsg( Error, Error, "already connected" );
- // bus->RemoveApplication( target );
target->Close();
}
}
@@ -348,7 +343,6 @@ void IvyApplication::OnClose(int nErrorCode)
delete iter->second;
regexp_in.clear();
Close();
- //bus->RemoveApplication( this );
}
int IvyApplication::SendMsg(const char *message)
diff --git a/Ivy/IvyApplication.h b/Ivy/IvyApplication.h
index 8132560..cd9b123 100644
--- a/Ivy/IvyApplication.h
+++ b/Ivy/IvyApplication.h
@@ -62,9 +62,6 @@ protected:
ivy::string appname;
bool AppConnectedCallbackCalled;
Ivy *bus;
- /* liste des souscriptions remote */
- /* en clair */
- ivy::map<int,ivy::string> regexp_str_in;
/* compile */
typedef ivy::map<int,IvyBinding *> Bindings;
Bindings regexp_in;
diff --git a/Ivy/IvyBinding.cxx b/Ivy/IvyBinding.cxx
index 7501d82..239d56a 100644
--- a/Ivy/IvyBinding.cxx
+++ b/Ivy/IvyBinding.cxx
@@ -59,10 +59,16 @@ IvyBinding::~IvyBinding()
delete regexp;
#endif /* USE_PCRE */
}
+const char* IvyBinding::getExpression()
+{
+ return expression_string.c_str();
+}
+
bool IvyBinding::Compile( const char * expression, int *erroffset, const char **errmessage )
{
int capture_count = 0;
bool compile = false;
+ expression_string = expression;
#ifdef USE_PCRE
regexp = pcre_compile(expression, PCRE_CASELESS, &err_buf, &err_offset, NULL);
if ( regexp != NULL )
diff --git a/Ivy/IvyBinding.h b/Ivy/IvyBinding.h
index 38d6533..4ea96ec 100644
--- a/Ivy/IvyBinding.h
+++ b/Ivy/IvyBinding.h
@@ -42,12 +42,12 @@ public:
/* Execution , extraction */
int Exec( const char * message );
void Match( const char *message, int argnum, int *arglen, const char **arg );
-
+
+ const char* getExpression();
private:
-#ifdef USE_PCRE
-#ifdef _DEBUG
+ /* Expression en clair */
std::string expression_string;
-#endif
+#ifdef USE_PCRE
pcre *regexp;
pcre_extra *inspect;
int ovectorsize;
diff --git a/Ivy/IvySynchroWnd.cxx b/Ivy/IvySynchroWnd.cxx
index 2109a61..2c84ad5 100644
--- a/Ivy/IvySynchroWnd.cxx
+++ b/Ivy/IvySynchroWnd.cxx
@@ -178,6 +178,7 @@ void IvySynchronousApplicationCallback::OnApplicationDisconnected( IvyApplicati
}
void IvySynchronousApplicationCallback::CallCallback()
{
+ if ( !target ) return;
switch ( type )
{
case CONNECTED_CB:
@@ -227,17 +228,20 @@ void IvySynchronousBindingCallback::OnFilterBind( IvyApplication *app, int id,
}
void IvySynchronousBindingCallback::CallCallback()
{
- switch ( type )
+ if ( target )
{
- case ADD_CB:
- target->OnAddBind( app, id, regexp );
- break;
- case REMOVE_CB:
- target->OnRemoveBind( app, id, regexp );
- break;
- case FILTER_CB:
- target->OnFilterBind( app, id, regexp );
- break;
+ switch ( type )
+ {
+ case ADD_CB:
+ target->OnAddBind( app, id, regexp );
+ break;
+ case REMOVE_CB:
+ target->OnRemoveBind( app, id, regexp );
+ break;
+ case FILTER_CB:
+ target->OnFilterBind( app, id, regexp );
+ break;
+ }
}
delete regexp;
} \ No newline at end of file
diff --git a/Ivy/IvyWatcher.cxx b/Ivy/IvyWatcher.cxx
index 4cbf604..ab72511 100644
--- a/Ivy/IvyWatcher.cxx
+++ b/Ivy/IvyWatcher.cxx
@@ -15,6 +15,7 @@
IvyWatcher::IvyWatcher(Ivy * bus)
{
+ running = false;
this->bus = bus;
}
IvyWatcher::~IvyWatcher()
@@ -97,6 +98,11 @@ void IvyWatcher::start(const char *domainlist)
}
// create UDP receiver
// catch exception !!!
+ // if already open then CLOSE
+ if ( running )
+ {
+ Close();
+ }
Socket(SOCK_DGRAM);
SetSockOpt( SO_REUSEADDR, &reuse, sizeof(BOOL) );
Bind(port);
@@ -117,8 +123,10 @@ void IvyWatcher::start(const char *domainlist)
AddMember( addr.c_str() );
SendTo( hello, len, port, addr.c_str() );
}
+ running = true;
}
void IvyWatcher::stop()
{
Close();
+ running = false;
}
diff --git a/Ivy/IvyWatcher.h b/Ivy/IvyWatcher.h
index 1eb0718..1ce8a2f 100644
--- a/Ivy/IvyWatcher.h
+++ b/Ivy/IvyWatcher.h
@@ -20,6 +20,7 @@ public:
public:
IvyWatcher(Ivy *bus);
virtual ~IvyWatcher();
+ bool IsRunning() { return running; };
// Overrides
public:
void start(const char *domain);
@@ -29,6 +30,6 @@ public:
// Implementation
protected:
Ivy * bus;
-
+ bool running;
};
diff --git a/Ivy/ThreadedSocket.cxx b/Ivy/ThreadedSocket.cxx
index 03b062e..99caa80 100644
--- a/Ivy/ThreadedSocket.cxx
+++ b/Ivy/ThreadedSocket.cxx
@@ -159,21 +159,32 @@ void CThreadedSocket::Close()
//ASSERT(SOCKET_ERROR != closesocket(m_hSocket));
SOCKET temp = m_hSocket; // Thread ACK
m_hSocket = INVALID_SOCKET;
- TRACE( "CThreadedSocket::Close (reader=0x%0lx) (writer=0x%0lx)\n", reader_id, writer_id );
+ TRACE( "CThreadedSocket::Close (current=0x%0lx) (reader=0x%0lx) (writer=0x%0lx)\n", currentThreadId, reader_id, writer_id );
closesocket(temp); // close silently
//if ( thread ) // On fait de l'auto delete mais dans le cas de terminaison anormale l'object reste ????!!!
// delete thread;
-// TRACE("CThreadedSocket waiting for thread end ...\n");
if ( h_reader && currentThreadId != reader_id )
- WaitForSingleObject( h_reader, 5000 );
+ {
+ TRACE("CThreadedSocket waiting for thread end (reader=0x%0lx)...\n",reader_id);
+ DWORD res = WaitForSingleObject( h_reader, INFINITE );
+ if ( res != WAIT_OBJECT_0 )
+ {
+ TRACE("CThreadedSocket waiting for thread end (reader=0x%0lx) error 0x%0lx lasterror 0x%0lx\n",reader_id,res, ::GetLastError());
+ }
+ }
// wake up writer
if ( h_writer && currentThreadId != writer_id )
{
+ TRACE("CThreadedSocket waiting for thread end (writer=0x%0lx)...\n",writer_id);
err = ReleaseSemaphore(send_count, 1, &PreviousCount);
- WaitForSingleObject( h_writer, 5000 );
+ DWORD res = WaitForSingleObject( h_writer, INFINITE );
+ if ( res != WAIT_OBJECT_0 )
+ {
+ TRACE("CThreadedSocket waiting for thread end (writer=0x%0lx) error 0x%0lx lasterror 0x%0lx\n",writer_id,res, ::GetLastError());
}
-// TRACE("CThreadedSocket all thread ended\n");
+ }
+ TRACE("CThreadedSocket all thread ended (reader=0x%0lx) (writer=0x%0lx)\n", reader_id, writer_id);
}
}
int CThreadedSocket::Listen(int nConnectionBacklog)
@@ -452,6 +463,12 @@ UINT CThreadedSocket::SocketReader( )
FD_SET(m_hSocket, &exceptfds);
err = select( 1, &readfds, &writefds, &exceptfds, NULL );
+ if (m_hSocket == INVALID_SOCKET)
+ {
+ TRACE( "CThreadedSocket::SocketThread no more Socket *********** !thread_id =( 0x%x) \n",reader_id);
+ return -1;
+ }
+
sock_err = this->GetLastError();
switch ( err )