Commit 83648b90 authored by Zack Weinberg's avatar Zack Weinberg
Browse files

Don't allow connection count to grow without limit in HTTP steg.

The fix involves two complementary changes: (1) restore the upper
limit of 64 outstanding downstream connections per circuit; (2) HTTP
steg needs to call ->cease_transmission() and ->expect_close() on its
connections at the right times (for now, unconditionally; in the
future, paying attention to the HTTP "Connection:" header).
parent e5429ffb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -479,7 +479,8 @@ chop_circuit_t::send()
    // reopening new connections.  If we're the server, we have to
    // just twiddle our thumbs and hope the client does that.
    if (no_target_connection) {
      if (config->mode != LSN_SIMPLE_SERVER)
      if (config->mode != LSN_SIMPLE_SERVER &&
          downstreams.size() < 64)
        circuit_reopen_downstreams(this);
      else
        circuit_arm_axe_timer(this, axe_interval());
+12 −1
Original line number Diff line number Diff line
@@ -588,7 +588,13 @@ http_steg_t::transmit(struct evbuffer *source)
      break;
    }

    if (rval == 0) have_transmitted = 1;
    if (rval == 0) {
      have_transmitted = 1;
      // FIXME: should decide whether or not to do this based on the
      // Connection: header.  (Needs additional changes elsewhere, esp.
      // in transmit_room.)
      conn->cease_transmission();
    }
    return rval;
  }
}
@@ -671,6 +677,11 @@ http_server_receive(http_steg_t *s, conn_t *conn, struct evbuffer *dest, struct
  s->have_received = 1;
  s->type = type;

  // FIXME: should decide whether or not to do this based on the
  // Connection: header.  (Needs additional changes elsewhere, esp.
  // in transmit_room.)
  conn->expect_close();

  conn->transmit_soon(100);
  return RECV_GOOD;
}
+0 −2
Original line number Diff line number Diff line
@@ -893,8 +893,6 @@ http_server_JS_transmit (payloads& pl, struct evbuffer *source, conn_t *conn,
  evbuffer_drain(source, sbuflen);

  free(outbuf2);
  conn->cease_transmission();
  //  downcast_steg(s)->have_transmitted = 1;
  return 0;
}

+0 −2
Original line number Diff line number Diff line
@@ -464,8 +464,6 @@ http_server_PDF_transmit(payloads &pl, struct evbuffer *source,
  }

  evbuffer_drain(source, sbuflen);

  conn->cease_transmission();
  return 0;
}

+0 −3
Original line number Diff line number Diff line
@@ -152,9 +152,6 @@ http_server_SWF_transmit(payloads& pl, struct evbuffer *source, conn_t *conn)
    return -1;
  }

    
  conn->cease_transmission();

  free(inbuf);
  free(outbuf);
  return 0;