Re: [Quickfix-developers] PATCH - Java crashes solved
Brought to you by:
orenmnero
From: <OM...@th...> - 2003-05-02 01:59:07
|
Well, I would be careful before making the assumption that the creation of C++ threads is the cause of the problem. This is a perfectly valid thing to do if you make a call to AttachCurrentThread (which is done). This article discusses this: http://www.complex-ite.net/tutorials/JDCBook/jniref.html#thrd JNI will often return a null pointer on one call when a previous call caused a serious problem in the JVM. Could be a synchronization problem ( either in QuickFIX or your callback code ). But I believe the core of the problem should be solvable without changing the semantics of the library. It is also essential for something like the ThreadedSocketAcceptor to exist at all! --oren |---------+-----------------------------------------------> | | Alex Hornby <al...@an...> | | | Sent by: | | | qui...@li...ur| | | ceforge.net | | | | | | | | | 05/01/2003 10:39 AM | | | | |---------+-----------------------------------------------> >----------------------------------------------------------------------------------------------| | | | To: Oren Miller <OM...@th...> | | cc: quickfix-developers <qui...@li...> | | Subject: [Quickfix-developers] PATCH - Java crashes solved | >----------------------------------------------------------------------------------------------| 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 ) { ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Quickfix-developers mailing list Qui...@li... https://lists.sourceforge.net/lists/listinfo/quickfix-developers |