Commit 61dc00bc authored by Roger Dingledine's avatar Roger Dingledine
Browse files

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


svn:r67
parent 1c3b823a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -8,8 +8,11 @@
/*
 * Changes :
 * $Log$
 * Revision 1.1  2002/06/26 22:45:50  arma
 * Initial revision
 * Revision 1.2  2002/07/20 02:01:18  arma
 * 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
 * Final finishes.
@@ -28,7 +31,7 @@
#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_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_BAD_REQUEST HTTPAP_VERSION " 400 Invalid syntax." HTTPAP_CRLF
#define HTTPAP_STATUS_LINE_UNEXPECTED HTTPAP_VERSION " 500 Internal server error." HTTPAP_CRLF
+13 −8
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@
/*
 * Changes :
 * $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
 * slightly less noisy
 *
@@ -97,9 +100,11 @@ void print_usage()
/* used for reaping zombie processes */
void sigchld_handler(int s)
{
  while (wait(NULL) > 0);
  while((waitpid (-1, NULL, WNOHANG)) > 0) {
//  while (wait(NULL) > 0);
    connections--;
  }
}

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;
  }
  log(LOG_DEBUG,"handle_connection : Client's version is : %s.",http_ver);
  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);
    write_tout(new_sock, HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED, strlen(HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED), conn_toutp);
    return -1;
  }
//  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);
//    write_tout(new_sock, HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED, strlen(HTTPAP_STATUS_LINE_VERSION_NOT_SUPPORTED), conn_toutp);
//    return -1;
//  }
  free((void *)http_ver);
  
  /* extract the destination address and port */