summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2009-10-24 13:32:09 +0000
committerAndrey Nazarov <skuller@skuller.net>2009-10-24 13:32:09 +0000
commit6cb756a67f484a405f52892bee49eef931e13869 (patch)
tree7348cd77a2b7807d30ac7f0bf4eb4ac6fd101487
parent3c9ade8c4efe39e7705ae117e74156cc8bc5e825 (diff)
NET_RunStream may now only reset ‘want’ flags on IO entries, but not set them back.
-rw-r--r--source/net_common.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/source/net_common.c b/source/net_common.c
index fed8438..0536b0b 100644
--- a/source/net_common.c
+++ b/source/net_common.c
@@ -1269,7 +1269,7 @@ neterr_t NET_RunStream( netstream_t *s ) {
}
e = IO_Get( s->socket );
- if( e->canread ) {
+ if( e->wantread && e->canread ) {
// read as much as we can
data = FIFO_Reserve( &s->recv, &len );
if( len ) {
@@ -1299,11 +1299,17 @@ neterr_t NET_RunStream( netstream_t *s ) {
net_bytes_rcvd += ret;
result = NET_OK;
+
+ // now see if there's more space to read
+ FIFO_Reserve( &s->recv, &len );
+ if( !len ) {
+ e->wantread = qfalse;
+ }
}
}
}
- if( e->canwrite ) {
+ if( e->wantwrite && e->canwrite ) {
// write as much as we can
data = FIFO_Peek( &s->send, &len );
if( len ) {
@@ -1333,16 +1339,17 @@ neterr_t NET_RunStream( netstream_t *s ) {
net_bytes_sent += ret;
//result = NET_OK;
+
+ // now see if there's more data to write
+ FIFO_Peek( &s->send, &len );
+ if( !len ) {
+ e->wantwrite = qfalse;
+ }
+
}
}
}
- FIFO_Reserve( &s->recv, &len );
- e->wantread = len ? qtrue : qfalse;
-
- FIFO_Peek( &s->send, &len );
- e->wantwrite = len ? qtrue : qfalse;
-
return result;
closed: