Skip to content

The LinkedBlockingQueue should not have a length. (currently 10) - #61

Closed
JohanSmolders wants to merge 1 commit into
TooTallNate:masterfrom
JohanSmolders:master
Closed

The LinkedBlockingQueue should not have a length. (currently 10)#61
JohanSmolders wants to merge 1 commit into
TooTallNate:masterfrom
JohanSmolders:master

Conversation

@JohanSmolders

Copy link
Copy Markdown

The LinkedBlockingQueue should not have a length.
If a message received has more then 10 messages being send back it
renders the socket useless. Since the bufferQueue.put() method keeps
waiting forever for the queue to shrink.

The LinkedBlockingQueue should not have a length.
If a message received has more then 10 messages being send back it
renders the socket useless.  Since the bufferQueue.put() method keeps
waiting forever for the queue to shrink.
@Davidiusdadi

Copy link
Copy Markdown
Collaborator

In the current situation reaching the buffers limit may cause a deadlock situation which is probably why you came up with this change.

Thanks for calling attention on that!

On the other hand this fix is not a long term solution because it makes it kind of easy to reach OutOfMemory states.
Just image a situation where you constantly send messages and the underlaying socket is not able to transport the data in time.

A better way would be to not increase the limit of the LinkedBlockingQueue to much but actively schedule the data transfer if the buffer is full. That would keep the buffer from constantly growing and would eliminate deadlock possibility.

If possible IO operations would be processed asynchronous but if not the IO operations would be performed by the thread calling the send.

@TooTallNate

We could also solve the problem AND gain performance by making the handling of all the SelectionKeys asynchronous which should not be such a huge thing.

@Davidiusdadi Davidiusdadi mentioned this pull request Mar 5, 2012
Davidiusdadi added a commit to Davidiusdadi/Java-WebSocket that referenced this pull request Mar 12, 2012
@komimima komimima mentioned this pull request Mar 14, 2012
@Davidiusdadi

Copy link
Copy Markdown
Collaborator

Ok, there should no longer be problems with the internal queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants