mirror of
				git://erdgeist.org/opentracker
				synced 2025-10-31 18:03:24 +08:00 
			
		
		
		
	Indent. Sorry. Plus timeout on every connection, for every byte we got.
This commit is contained in:
		
							parent
							
								
									bef60daf2b
								
							
						
					
					
						commit
						1d66041fd5
					
				| @ -386,25 +386,19 @@ allparsed: | |||||||
| 
 | 
 | ||||||
|   io_wantread(s); |   io_wantread(s); | ||||||
| 
 | 
 | ||||||
|     for (;;) |   for (;;) { | ||||||
|     { |  | ||||||
|     int64 i; |     int64 i; | ||||||
|     io_wait(); |     io_wait(); | ||||||
| 
 | 
 | ||||||
|         while ((i=io_canread())!=-1) |     while ((i=io_canread())!=-1) { | ||||||
|         { |       if (i==s) { // ist es der serversocket?
 | ||||||
|             if (i==s)    // ist es der serversocket?
 |  | ||||||
|             { |  | ||||||
|         int n; |         int n; | ||||||
|                 while ((n=socket_accept4(s,(void*)&ip,&port))!=-1) |         while ((n=socket_accept4(s,(void*)&ip,&port))!=-1) { | ||||||
|                 { |           if (io_fd(n)) { | ||||||
|                     if (io_fd(n)) |  | ||||||
|                     { |  | ||||||
|             struct http_data* h=(struct http_data*)malloc(sizeof(struct http_data)); |             struct http_data* h=(struct http_data*)malloc(sizeof(struct http_data)); | ||||||
|             io_wantread(n); |             io_wantread(n); | ||||||
| 
 | 
 | ||||||
|                         if (h) |             if (h) { | ||||||
|                         { |  | ||||||
|               byte_zero(h,sizeof(struct http_data)); |               byte_zero(h,sizeof(struct http_data)); | ||||||
|               h->ip=ip; |               h->ip=ip; | ||||||
|               taia_now(&t); |               taia_now(&t); | ||||||
| @ -421,24 +415,18 @@ allparsed: | |||||||
|           io_eagain(s); |           io_eagain(s); | ||||||
|         else |         else | ||||||
|           carp("socket_accept4"); |           carp("socket_accept4"); | ||||||
|             } |       } else { | ||||||
|             else |  | ||||||
|             { |  | ||||||
|         char buf[8192]; |         char buf[8192]; | ||||||
|         struct http_data* h=io_getcookie(i); |         struct http_data* h=io_getcookie(i); | ||||||
| 
 | 
 | ||||||
|         int l=io_tryread(i,buf,sizeof buf); |         int l=io_tryread(i,buf,sizeof buf); | ||||||
|                 if (l<=0) |         if( l <= 0 ) { | ||||||
|                 { |           if( h ) { | ||||||
|                     if (h) |  | ||||||
|                     { |  | ||||||
|             array_reset(&h->r); |             array_reset(&h->r); | ||||||
|             free(h); |             free(h); | ||||||
|           } |           } | ||||||
|           io_close(i); |           io_close(i); | ||||||
|                 } |         } else { | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|           array_catb(&h->r,buf,l); |           array_catb(&h->r,buf,l); | ||||||
| 
 | 
 | ||||||
|           if( array_failed(&h->r)) |           if( array_failed(&h->r)) | ||||||
| @ -447,20 +435,23 @@ allparsed: | |||||||
|             httperror(i,h,"500 request too long","You sent too much headers"); |             httperror(i,h,"500 request too long","You sent too much headers"); | ||||||
|           else if ((l=header_complete(h))) |           else if ((l=header_complete(h))) | ||||||
|             httpresponse(i,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); |       struct http_data* h=io_getcookie(i); | ||||||
| 
 | 
 | ||||||
|       int64 r=iob_send(i,&h->iob); |       int64 r=iob_send(i,&h->iob); | ||||||
|       if (r==-1) |       if (r==-1) | ||||||
|         io_eagain(i); |         io_eagain(i); | ||||||
|       else |       else | ||||||
|                 if ((r<=0)||(h->iob.bytesleft==0)) |         if ((r<=0)||(h->iob.bytesleft==0)) { | ||||||
|                 { |  | ||||||
|           iob_reset(&h->iob); |           iob_reset(&h->iob); | ||||||
|           free(h); |           free(h); | ||||||
|           io_close(i); |           io_close(i); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 erdgeist
						erdgeist