Hi Oren,
Heres a patch that adds a blockingStart() method to the Acceptor class
and makes the java SocketAcceptor wrapper use it.
This is useful because it means there is no long a requirement for C++
thread creation in the call stack from Java.
This is vital for the JVM, as if a thread is created in C++ via
pthread_create() the JVM won't return an environment for it from
ENV::get(). This was the cause of a lot out our java crashes, as when
the environment is unknown a null pointer is returned (and then used).
ChangeLog entry below.
2003-05-01 Alex Hornby <al...@an...>
* src/java/org_quickfix_SocketAcceptor.cpp: use blockingStart to
start acceptor. This is important as it means that the thread can be
created in java rather than in C++, which means that the JVM
knows about it and can give sensible results in ENV::get().
* src/C++/Application.h: add blockingStart method
* src/C++/Application.cpp: add blockingStart method
Cheers,
Alex.
Index: src/C++/Acceptor.h
===================================================================
RCS file: /cvsroot/quickfix/quickfix/src/C++/Acceptor.h,v
retrieving revision 1.7
diff -u -r1.7 Acceptor.h
--- src/C++/Acceptor.h 10 Apr 2003 05:13:31 -0000 1.7
+++ src/C++/Acceptor.h 1 May 2003 15:28:29 -0000
@@ -89,6 +89,9 @@
/// Start acceptor.
void start() throw ( ConfigError&, RuntimeError& );
+ void blockingStart() throw ( ConfigError&, RuntimeError& );
+
+
/// Stop acceptor.
void stop();
Index: src/C++/Acceptor.cpp
===================================================================
RCS file: /cvsroot/quickfix/quickfix/src/C++/Acceptor.cpp,v
retrieving revision 1.9
diff -u -r1.9 Acceptor.cpp
--- src/C++/Acceptor.cpp 10 Apr 2003 05:13:31 -0000 1.9
+++ src/C++/Acceptor.cpp 1 May 2003 15:28:30 -0000
@@ -168,6 +168,17 @@
QF_STACK_POP
}
+void Acceptor::blockingStart() throw ( ConfigError&, RuntimeError& )
+{ QF_STACK_PUSH( Acceptor::start )
+
+ onConfigure( m_settings );
+ onInitialize( m_settings );
+
+ startThread(this);
+
+ QF_STACK_POP
+}
+
void Acceptor::stop()
{ QF_STACK_PUSH( Acceptor::stop )
Index: src/java/org_quickfix_SocketAcceptor.cpp
===================================================================
RCS file: /cvsroot/quickfix/quickfix/src/java/org_quickfix_SocketAcceptor.cpp,v
retrieving revision 1.7
diff -u -r1.7 org_quickfix_SocketAcceptor.cpp
--- src/java/org_quickfix_SocketAcceptor.cpp 29 Mar 2003 08:26:17 -0000 1.7
+++ src/java/org_quickfix_SocketAcceptor.cpp 1 May 2003 15:28:30 -0000
@@ -139,7 +139,7 @@
JVM::set( pEnv );
try
{
- getCPPSocketAcceptor( obj ) ->start();
+ getCPPSocketAcceptor( obj ) ->blockingStart();
}
catch( FIX::ConfigError &e )
{
|