RE: [Asterisk-java-users] ManagerReader Interrupt
Brought to you by:
srt
From: King H. <kin...@ne...> - 2006-03-04 11:31:43
|
I think I have also been bitten by this stray "interrupt" but I have not = gone so far as to track down where it was thrown.=20 I was having a queue.take() waiting for commands to send to the Asterisk = but it was being interrupted all the time :( =20 I have since changed to starting a new thread for each command to send = to Asterisk instead. I think this has the added benefit that a stuck = connection will not hang the whole program. King -----Original Message----- From: ast...@li... = [mailto:ast...@li...] On Behalf Of = Brett Sutton Sent: Saturday, March 04, 2006 7:19 PM To: ast...@li... Subject: [Asterisk-java-users] ManagerReader Interrupt I believe that there is a bug in the=20 DefaultManagerConnection.sendAction(ManagerAction action, long timeout)=20 method. The problem is with the creation of the ResponseHandlerResult. The ResponseHandlerResult calls thread.interrupt to wake up the thread=20 which called sendAction. Thats fine, the problem begins when the=20 sendAction returns (with or without a response). Calling Thread.interupt leaves the thread in an interrupted state until=20 some method (such as sleep) checks the threads interrupt state at which=20 point the interrupt state is cleared. The problem occurs if the call to interrupt is made when sendAction is=20 not currently sleeping. There are numerous ways in which this can = happen. The impact on sendAction is zero. However if an application then calls a = method such as Thread.sleep or Queue.take the method call will=20 immediately throw an Interrupted exception as the thread is still in an=20 interrupted state. I believe a better way of dealing with this problem is to use=20 Object.wait(x) and Object.notify. For the purposes of sendAction the=20 affects are identical without the nasty side effects of calling = interrupt. I hope this makes some sense. Regards, Brett. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting = language that extends applications into web and mobile media. Attend the live = webcast and join the prime developer group breaking into this new coding = territory! http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=3D= 121642 _______________________________________________ Asterisk-java-users mailing list Ast...@li... https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |