Commit f47fe829 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

avoid racing the mark-for-close when the client hangs up on us

at the same time we get an end relay cell.
(thanks to wmf for reminding me)


svn:r2181
parent 658e02a6
Loading
Loading
Loading
Loading
+4 −0
Changes for src/or/connection_edge.c: 4 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
@@ -54,7 +54,11 @@ int connection_edge_process_inbuf(connection_t *conn) {
    /* eof reached, kill it. */
    /* eof reached, kill it. */
    log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
    log_fn(LOG_INFO,"conn (fd %d) reached eof. Closing.", conn->s);
    connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
    connection_edge_end(conn, END_STREAM_REASON_DONE, conn->cpath_layer);
    if(!conn->marked_for_close) {
      /* only mark it if not already marked. it's possible to
       * get the 'end' right around when the client hangs up on us. */
      connection_mark_for_close(conn);
      connection_mark_for_close(conn);
    }
    conn->hold_open_until_flushed = 1; /* just because we shouldn't read
    conn->hold_open_until_flushed = 1; /* just because we shouldn't read
                                          doesn't mean we shouldn't write */
                                          doesn't mean we shouldn't write */
    return 0;
    return 0;
+4 −0
Changes for src/or/relay.c: 4 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
@@ -694,7 +694,11 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
#else
#else
      /* We just *got* an end; no reason to send one. */
      /* We just *got* an end; no reason to send one. */
      conn->has_sent_end = 1;
      conn->has_sent_end = 1;
      if(!conn->marked_for_close) {
        /* only mark it if not already marked. it's possible to
         * get the 'end' right around when the client hangs up on us. */
        connection_mark_for_close(conn);
        connection_mark_for_close(conn);
      }
      conn->hold_open_until_flushed = 1;
      conn->hold_open_until_flushed = 1;
#endif
#endif
      return 0;
      return 0;