-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve Outbound Deadlock Issue #28
base: master
Are you sure you want to change the base?
Conversation
@@ -12,7 +14,8 @@ | |||
public class OutboundChannelInitializer extends ChannelInitializer<SocketChannel> { | |||
|
|||
private final IClientHandlerFactory clientHandlerFactory; | |||
private ExecutorService callbackExecutor = Executors.newSingleThreadExecutor(); | |||
private ExecutorService callbackExecutor = Executors.newFixedThreadPool(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can change the callbackExecutor
with the method setCallbackExecutor
outside whatever you want, without modify the OutboundChannelInitializer
inside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to modify the default callbackExecutor
from SingleThreadExecutor
to FixedThreadPool(2)
for default execution by OutboundClientHandler
, one being for handling ESL
events and another for command-response
. This is default behavior change hence changed here. Someone can still override and set it to much larger pool based on use-case by calling the setCallbackExecutor
.
Incase you think this should be still newSingleThreadExecutor
and OutboundClientHandler
should all times override this, then I can make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kingster Whenever you created a different EventExecutorGroup for the handler you don't need to make it two for the command-response messages. It will be handled by EventExecutorGroup thread
A thread pool with 2 thread, one being for handling ESL events and another for command-response.
That was a gread idea.
On 6/4/2019 17:14,Kinshuk Bairagi<notifications@github.com> wrote:
@kingster commented on this pull request.
In src/main/java/org/freeswitch/esl/client/outbound/OutboundChannelInitializer.java:
@@ -12,7 +14,8 @@
public class OutboundChannelInitializer extends ChannelInitializer<SocketChannel> {
private final IClientHandlerFactory clientHandlerFactory;
- private ExecutorService callbackExecutor = Executors.newSingleThreadExecutor();
+ private ExecutorService callbackExecutor = Executors.newFixedThreadPool(2);
I wanted to modify the default callbackExecutor from SingleThreadExecutor to FixedThreadPool(2) for default execution by OutboundClientHandler, one being for handling ESL events and another for command-response. This is default behavior change hence changed here. Someone can still override and set it to much larger pool based on use-case by calling the setCallbackExecutor.
Incase you think this should be still newSingleThreadExecutor and OutboundClientHandler should all times override this, then I can make that change.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Can you offer some Outbound Deadlock case ?
or
|
@livem This is what I am using at fs side
|
I have changed the code just like you,and I am using it like
and I am using it at fs side just like you too,but outbound still doesn't work.This is the fs's log:
but when I am using
it works. |
A |
@kingster |
The deadlock used to happen due to the
clientHandler.onConnect
handler being run on a sync thread. Hence any sync method would get blocked. AsyncApi still used to work, but the example provided was broken. WithonConnect
running on a separate thread the netty handler is released for further processing of responses which would complete the pending future.Resolve #13