Skip to content
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.

OutputWriter can't handle multiple writers #38

Closed
glassfishrobot opened this issue Oct 31, 2007 · 9 comments
Closed

OutputWriter can't handle multiple writers #38

glassfishrobot opened this issue Oct 31, 2007 · 9 comments

Comments

@glassfishrobot
Copy link

The OutputWriter class is intended to wait up to 1 minute (default wait time)
for output space to be available to complete writing the data. In an HTTP mode
(or for similar protocols), that works just fine.

For protocols (like SIP) where multiple threads are writing to the same socket,
buffer contention will cause OutputWriter to report an error prematurely. Say
there are 10 threads writing on the socket that fills up; all 10 will get a
selector and enter the select() call. When the socket buffer empties, all 10
will get notified that they can write data, and all will attempt to write their
data – but while the socket is still draining, it's likely that only 1 will
succeed and the remaining will write 0 bytes again. If this process is repeated
twice, the remaining sockets will give up (based on the attempts value in
OutputWriter) and close the socket. This entire process takes only a few
milliseconds, since during that time there will be two successful writes.

The async queueing model should take this into account, or we should develop a
selector-per-socket model such that only one thread can wake up from the select
at a time.

Environment

Operating System: All
Platform: All

@glassfishrobot
Copy link
Author

Reported by sdo@java.net

@glassfishrobot
Copy link
Author

Was assigned to oleksiys@java.net

@glassfishrobot
Copy link
Author

oleksiys@java.net said:
I'm not familiar with SIP protocol, but for me it's difficult to imagine how
it's possible to write data to single socket simultaneously from several threads.
Isn't it required to synchronize data writing on socket object?

@glassfishrobot
Copy link
Author

jfarcand@java.net said:
I've fixed the problem in Sailfin by adding a simple write lock. I'm leaving
this bug open and will document the API so people are aware they need to sync
when writting.

@glassfishrobot
Copy link
Author

jfarcand@java.net said:
This has been fixed with Alexey's async read/write queue new feature.

@glassfishrobot
Copy link
Author

jfarcand@java.net said:
Fixed

@glassfishrobot
Copy link
Author

jfarcand@java.net said:
Fix milestones

@glassfishrobot
Copy link
Author

Marked as fixed on Wednesday, December 16th 2009, 6:14:11 pm

@glassfishrobot
Copy link
Author

This issue was imported from java.net JIRA GRIZZLY-38

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant