You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2007/04/13 17:32:20 UTC
svn commit: r528524 -
/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Author: fhanik
Date: Fri Apr 13 08:32:19 2007
New Revision: 528524
URL: http://svn.apache.org/viewvc?view=rev&rev=528524
Log:
This write has to be synchronized since comet can write to the buffer and cause a buffer overflow if more than one thread is writing
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?view=diff&rev=528524&r1=528523&r2=528524
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Fri Apr 13 08:32:19 2007
@@ -603,7 +603,7 @@
}
int total = 0;
- private void addToBB(byte[] buf, int offset, int length) throws IOException {
+ private synchronized void addToBB(byte[] buf, int offset, int length) throws IOException {
if (socket.getBufHandler().getWriteBuffer().remaining() < length) {
flushBuffer();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r528524 - /tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Posted by Remy Maucherat <re...@apache.org>.
Filip Hanik - Dev Lists wrote:
> I agree with you, but I'll save the rework of some of this for the next
> release, I believe I got the connector to a stable point now, don't
> wanna muck too much with it.
I would veto adding syncs, obviously.
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r528524 - /tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Remy Maucherat wrote:
> Filip Hanik - Dev Lists wrote:
>> Lets say you have two threads writing to the response (async write
>> from comet)
>> both of them could end up on the line:
>> socket.getBufHandler().getWriteBuffer().put(buf, offset, length);
>>
>> assuming nothing is synced in the path down to here, hence causing a
>> buffer overflow,
>> Does that makes sense or am I smoking crack?
>
> I know, but this doesn't make sense to me, since it will already do
> thread safety problems in the servlet layer (where there are buffers,
> etc). If people want to have more than one thread writing, they have
> to sync. I will not be adding similar checks in the APR connector, but
> you can leave them in the NIO connector if you feel more comfortable
> with them.
I agree with you, but I'll save the rework of some of this for the next
release, I believe I got the connector to a stable point now, don't
wanna muck too much with it.
Filip
>
> Rémy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r528524 - /tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Posted by Remy Maucherat <re...@apache.org>.
Filip Hanik - Dev Lists wrote:
> Lets say you have two threads writing to the response (async write from
> comet)
> both of them could end up on the line:
> socket.getBufHandler().getWriteBuffer().put(buf, offset, length);
>
> assuming nothing is synced in the path down to here, hence causing a
> buffer overflow,
> Does that makes sense or am I smoking crack?
I know, but this doesn't make sense to me, since it will already do
thread safety problems in the servlet layer (where there are buffers,
etc). If people want to have more than one thread writing, they have to
sync. I will not be adding similar checks in the APR connector, but you
can leave them in the NIO connector if you feel more comfortable with them.
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r528524 - /tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Remy Maucherat wrote:
> fhanik@apache.org wrote:
>> Author: fhanik
>> Date: Fri Apr 13 08:32:19 2007
>> New Revision: 528524
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=528524
>> Log:
>> This write has to be synchronized since comet can write to the buffer
>> and cause a buffer overflow if more than one thread is writing
>
> That's reverting 467065. I still don't see how concurrent writing in
> the servlet is going to work (nothing is synced, and everything is
> buffered to some extent).
Lets say you have two threads writing to the response (async write from
comet)
both of them could end up on the line:
socket.getBufHandler().getWriteBuffer().put(buf, offset, length);
assuming nothing is synced in the path down to here, hence causing a
buffer overflow,
Does that makes sense or am I smoking crack?
Filip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r528524 - /tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
Posted by Remy Maucherat <re...@apache.org>.
fhanik@apache.org wrote:
> Author: fhanik
> Date: Fri Apr 13 08:32:19 2007
> New Revision: 528524
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=528524
> Log:
> This write has to be synchronized since comet can write to the buffer and cause a buffer overflow if more than one thread is writing
That's reverting 467065. I still don't see how concurrent writing in the
servlet is going to work (nothing is synced, and everything is buffered
to some extent).
Rémy
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org