httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject cvs commit: httpd-proxy/module-2.0 proxy_connect.c
Date Sun, 08 Apr 2001 14:52:20 GMT
minfrin     01/04/08 07:52:20

  Modified:    module-2.0 proxy_connect.c
  Log:
  More error checks to make sure the poll() loop dies when the connection
  on either side is closed...
  
  Revision  Changes    Path
  1.31      +24 -21    httpd-proxy/module-2.0/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_connect.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- proxy_connect.c	2001/04/08 12:54:34	1.30
  +++ proxy_connect.c	2001/04/08 14:52:19	1.31
  @@ -324,66 +324,69 @@
               "proxy: CONNECT: error creating client apr_socket_t");
           return HTTP_INTERNAL_SERVER_ERROR;
       }
  -    apr_poll_socket_add(pollfd, client_sock, APR_POLLIN);
  +/*    apr_poll_socket_add(pollfd, client_sock, APR_POLLIN);*/
   #endif
  +    apr_poll_socket_add(pollfd, r->connection->client_socket, APR_POLLIN);
   
       /* Add the server side to the poll */
       apr_poll_socket_add(pollfd, sock, APR_POLLIN);
  -    apr_poll_socket_add(pollfd, r->connection->client_socket, APR_POLLIN);
   
       while (1) { /* Infinite loop until error (one side closes the connection) */
  -        ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: CONNECT:
going to sleep (poll)");
  -        if(apr_poll(pollfd, &pollcnt, -1) != APR_SUCCESS)
  +/*	ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: CONNECT:
going to sleep (poll)");*/
  +        if (apr_poll(pollfd, &pollcnt, -1) != APR_SUCCESS)
           {
   	    apr_socket_close(sock);
               ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "proxy: CONNECT: error apr_poll()");
               return HTTP_INTERNAL_SERVER_ERROR;
           }
  -        ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  -                     "proxy: CONNECT: woke from select(), i=%d", pollcnt);
  +/*	ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  +                     "proxy: CONNECT: woke from select(), i=%d", pollcnt);*/
   
           if (pollcnt) {
  -            apr_poll_revents_get(&pollevent, sock, pollfd);
  +	    apr_poll_revents_get(&pollevent, sock, pollfd);
               if (pollevent & APR_POLLIN) {
  -                ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  -                             "proxy: CONNECT: sock was set");
  -                nbytes = HUGE_STRING_LEN;
  -                if(apr_recv(sock, buffer, &nbytes) == APR_SUCCESS) {
  +/*		ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  +                             "proxy: CONNECT: sock was set");*/
  +                nbytes = sizeof(buffer);
  +                if (apr_recv(sock, buffer, &nbytes) == APR_SUCCESS) {
                       int o = 0;
                       while(nbytes)
                       {
                           i = nbytes;
  -                        apr_send(r->connection->client_socket, buffer + o, &i);
  +			if (apr_send(r->connection->client_socket, buffer + o, &i) != APR_SUCCESS)
  +			    break;
                           o += i;
                           nbytes -= i;
                       }
  -                    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  -				 "proxy: CONNECT: wrote %d bytes to client", nbytes);
                   }
                   else
                       break;
               }
  +            else if ((pollevent & APR_POLLERR) || (pollevent & APR_POLLHUP))
  +		break;
  +
   
               apr_poll_revents_get(&pollevent, r->connection->client_socket, pollfd);
               if (pollevent & APR_POLLIN) {
  -                ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  -                             "proxy: CONNECT: client was set");
  -                nbytes = HUGE_STRING_LEN;
  -                if(apr_recv(r->connection->client_socket, buffer, &nbytes) ==
APR_SUCCESS) {
  +/*		ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
  +                             "proxy: CONNECT: client was set");*/
  +                nbytes = sizeof(buffer);
  +                if (apr_recv(r->connection->client_socket, buffer, &nbytes) ==
APR_SUCCESS) {
                       int o = 0;
                       while(nbytes)
                       {
                           i = nbytes;
  -                        apr_send(sock, buffer + o, &i);
  +			if (apr_send(sock, buffer + o, &i) != APR_SUCCESS)
  +			    break;
                           o += i;
                           nbytes -= i;
                       }
  -                    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
  -                        r->server, "proxy: CONNECT: wrote %d bytes to server", nbytes);
                   }
                   else
                       break;
               }
  +            else if ((pollevent & APR_POLLERR) || (pollevent & APR_POLLHUP))
  +		break;
           }
           else
               break;
  
  
  

Mime
View raw message