You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/05 20:51:58 UTC
svn commit: r1490001 - /tomcat/native/branches/1.1.x/native/src/network.c
Author: markt
Date: Wed Jun 5 18:51:58 2013
New Revision: 1490001
URL: http://svn.apache.org/r1490001
Log:
Make sockets useable for non-blocking IO. Return bytes written if >0 and error code is EAGAIN rather than the error code so the clients know how many bytes were written.
Modified:
tomcat/native/branches/1.1.x/native/src/network.c
Modified: tomcat/native/branches/1.1.x/native/src/network.c
URL: http://svn.apache.org/viewvc/tomcat/native/branches/1.1.x/native/src/network.c?rev=1490001&r1=1490000&r2=1490001&view=diff
==============================================================================
--- tomcat/native/branches/1.1.x/native/src/network.c (original)
+++ tomcat/native/branches/1.1.x/native/src/network.c Wed Jun 5 18:51:58 2013
@@ -459,7 +459,7 @@ TCN_IMPLEMENT_CALL(jint, Socket, send)(T
ss = (*s->net->send)(s->opaque, (const char *)sb, &nbytes);
free(sb);
}
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && nbytes > 0))
return (jint)nbytes;
else {
TCN_ERROR_WRAP(ss);
@@ -532,7 +532,7 @@ TCN_IMPLEMENT_CALL(jint, Socket, sendb)(
sent += wr;
}
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && sent > 0))
return (jint)sent;
else {
TCN_ERROR_WRAP(ss);
@@ -566,7 +566,7 @@ TCN_IMPLEMENT_CALL(jint, Socket, sendib)
ss = (*s->net->send)(s->opaque, bytes + offset, &nbytes);
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && nbytes > 0))
return (jint)nbytes;
else {
TCN_ERROR_WRAP(ss);
@@ -603,7 +603,7 @@ TCN_IMPLEMENT_CALL(jint, Socket, sendbb)
break;
sent += wr;
}
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && sent > 0))
return (jint)sent;
else {
TCN_ERROR_WRAP(ss);
@@ -634,11 +634,11 @@ TCN_IMPLEMENT_CALL(jint, Socket, sendibb
ss = (*s->net->send)(s->opaque, s->jsbbuff + offset, &nbytes);
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && nbytes > 0))
return (jint)nbytes;
else {
TCN_ERROR_WRAP(ss);
- return -(jint)nbytes;
+ return -(jint)ss;
}
}
@@ -672,7 +672,7 @@ TCN_IMPLEMENT_CALL(jint, Socket, sendv)(
for (i = 0; i < nvec; i++) {
(*e)->ReleaseByteArrayElements(e, ba[i], (jbyte*)vec[i].iov_base, JNI_ABORT);
}
- if (ss == APR_SUCCESS)
+ if (ss == APR_SUCCESS || ((APR_STATUS_IS_EAGAIN(ss) || ss == TCN_EAGAIN) && written > 0))
return (jint)written;
else {
TCN_ERROR_WRAP(ss);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org