bugfixes: don't hang waiting for new children to die; accept HTTP/1.1

svn:r67
This commit is contained in:
Roger Dingledine 2002-07-20 02:01:18 +00:00
parent 1c3b823a82
commit 61dc00bcaa
2 changed files with 19 additions and 11 deletions

View File

@ -8,8 +8,11 @@
/* /*
* Changes : * Changes :
* $Log$ * $Log$
* Revision 1.1 2002/06/26 22:45:50 arma * Revision 1.2 2002/07/20 02:01:18 arma
* Initial revision * bugfixes: don't hang waiting for new children to die; accept HTTP/1.1
*
* Revision 1.1.1.1 2002/06/26 22:45:50 arma
* initial commit: current code
* *
* Revision 1.2 2002/04/02 14:27:33 badbytes * Revision 1.2 2002/04/02 14:27:33 badbytes
* Final finishes. * Final finishes.
@ -28,7 +31,7 @@
#define HTTPAP_VERSION "HTTP/1.0" #define HTTPAP_VERSION "HTTP/1.0"
#define HTTPAP_STATUS_LINE_FORBIDDEN HTTPAP_VERSION " 403 Only local connections are allowed." HTTPAP_CRLF #define HTTPAP_STATUS_LINE_FORBIDDEN HTTPAP_VERSION " 403 Only local connections are allowed." HTTPAP_CRLF
#define HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED HTTPAP_VERSION " 505 Only HTTP/1.0 is supported." HTTPAP_CRLF #define HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED HTTPAP_VERSION " 501 Only HTTP/1.0 is supported." HTTPAP_CRLF
#define HTTPAP_STATUS_LINE_UNAVAILABLE HTTPAP_VERSION " 503 Connection to the server failed." HTTPAP_CRLF #define HTTPAP_STATUS_LINE_UNAVAILABLE HTTPAP_VERSION " 503 Connection to the server failed." HTTPAP_CRLF
#define HTTPAP_STATUS_LINE_BAD_REQUEST HTTPAP_VERSION " 400 Invalid syntax." HTTPAP_CRLF #define HTTPAP_STATUS_LINE_BAD_REQUEST HTTPAP_VERSION " 400 Invalid syntax." HTTPAP_CRLF
#define HTTPAP_STATUS_LINE_UNEXPECTED HTTPAP_VERSION " 500 Internal server error." HTTPAP_CRLF #define HTTPAP_STATUS_LINE_UNEXPECTED HTTPAP_VERSION " 500 Internal server error." HTTPAP_CRLF

View File

@ -8,6 +8,9 @@
/* /*
* Changes : * Changes :
* $Log$ * $Log$
* Revision 1.5 2002/07/20 02:01:18 arma
* bugfixes: don't hang waiting for new children to die; accept HTTP/1.1
*
* Revision 1.4 2002/07/19 18:48:19 arma * Revision 1.4 2002/07/19 18:48:19 arma
* slightly less noisy * slightly less noisy
* *
@ -97,8 +100,10 @@ void print_usage()
/* used for reaping zombie processes */ /* used for reaping zombie processes */
void sigchld_handler(int s) void sigchld_handler(int s)
{ {
while (wait(NULL) > 0); while((waitpid (-1, NULL, WNOHANG)) > 0) {
connections--; // while (wait(NULL) > 0);
connections--;
}
} }
int handle_connection(int new_sock, struct hostent *local, struct sockaddr_in remote, uint16_t op_port) int handle_connection(int new_sock, struct hostent *local, struct sockaddr_in remote, uint16_t op_port)
@ -177,12 +182,12 @@ int handle_connection(int new_sock, struct hostent *local, struct sockaddr_in re
return -1; return -1;
} }
log(LOG_DEBUG,"handle_connection : Client's version is : %s.",http_ver); log(LOG_DEBUG,"handle_connection : Client's version is : %s.",http_ver);
if (strcmp(http_ver, HTTPAP_VERSION)) /* not supported */ // if (strcmp(http_ver, HTTPAP_VERSION)) /* not supported */
{ // {
log(LOG_DEBUG,"handle_connection : Client's version is %s, I only support HTTP/1.0.",http_ver); // log(LOG_DEBUG,"handle_connection : Client's version is %s, I only support HTTP/1.0.",http_ver);
write_tout(new_sock, HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED, strlen(HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED), conn_toutp); // write_tout(new_sock, HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED, strlen(HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED), conn_toutp);
return -1; // return -1;
} // }
free((void *)http_ver); free((void *)http_ver);
/* extract the destination address and port */ /* extract the destination address and port */