Browse Source

Indent. Sorry. Plus timeout on every connection, for every byte we got.

dynamic-accesslists
erdgeist 18 years ago
parent
commit
1d66041fd5
  1. 43
      opentracker.c

43
opentracker.c

@ -386,25 +386,19 @@ allparsed: @@ -386,25 +386,19 @@ allparsed:
io_wantread(s);
for (;;)
{
for (;;) {
int64 i;
io_wait();
while ((i=io_canread())!=-1)
{
if (i==s) // ist es der serversocket?
{
while ((i=io_canread())!=-1) {
if (i==s) { // ist es der serversocket?
int n;
while ((n=socket_accept4(s,(void*)&ip,&port))!=-1)
{
if (io_fd(n))
{
while ((n=socket_accept4(s,(void*)&ip,&port))!=-1) {
if (io_fd(n)) {
struct http_data* h=(struct http_data*)malloc(sizeof(struct http_data));
io_wantread(n);
if (h)
{
if (h) {
byte_zero(h,sizeof(struct http_data));
h->ip=ip;
taia_now(&t);
@ -421,24 +415,18 @@ allparsed: @@ -421,24 +415,18 @@ allparsed:
io_eagain(s);
else
carp("socket_accept4");
}
else
{
} else {
char buf[8192];
struct http_data* h=io_getcookie(i);
int l=io_tryread(i,buf,sizeof buf);
if (l<=0)
{
if (h)
{
if( l <= 0 ) {
if( h ) {
array_reset(&h->r);
free(h);
}
io_close(i);
}
else
{
} else {
array_catb(&h->r,buf,l);
if( array_failed(&h->r))
@ -447,20 +435,23 @@ allparsed: @@ -447,20 +435,23 @@ allparsed:
httperror(i,h,"500 request too long","You sent too much headers");
else if ((l=header_complete(h)))
httpresponse(i,h);
else {
taia_now(&t);
taia_addsec(&t,&t,OT_CLIENT_TIMEOUT);
io_timeout(i,t);
}
}
}
}
while ((i=io_canwrite())!=-1)
{
while ((i=io_canwrite())!=-1) {
struct http_data* h=io_getcookie(i);
int64 r=iob_send(i,&h->iob);
if (r==-1)
io_eagain(i);
else
if ((r<=0)||(h->iob.bytesleft==0))
{
if ((r<=0)||(h->iob.bytesleft==0)) {
iob_reset(&h->iob);
free(h);
io_close(i);

Loading…
Cancel
Save