Ticket #938: mod_proxy.c.patch

File mod_proxy.c.patch, 0.9 kB (added by rlynch, 21 months ago)

Patch to retry reads on EAGAIN

  • src/mod_proxy.c.

    old new  
    655655                        buffer_prepare_append(hctx->response, hctx->response->used + b); 
    656656                } 
    657657                 
    658                 if (-1 == (r = read(hctx->fd, hctx->response->ptr + hctx->response->used - 1, b))) { 
    659                         log_error_write(srv, __FILE__, __LINE__, "sds",  
    660                                         "unexpected end-of-file (perhaps the proxy process died):", 
    661                                         proxy_fd, strerror(errno)); 
    662                         return -1; 
     658                 
     659                { 
     660                        int i = 0; 
     661                        for (;;++i) { 
     662                                if (-1 == (r = read(hctx->fd, hctx->response->ptr + hctx->response->used - 1, b))) { 
     663                                        if (errno == EAGAIN && i < 3) { 
     664                                                sleep(1); 
     665                                        } 
     666                                        else { 
     667                                                log_error_write(srv, __FILE__, __LINE__, "sds",  
     668                                                "unexpected end-of-file (perhaps the proxy process died):", 
     669                                                proxy_fd, strerror(errno)); 
     670                                                return -1; 
     671                                        } 
     672                                } 
     673                                else break; 
     674                        } 
    663675                } 
    664676                 
    665677                /* this should be catched by the b > 0 above */