private void flushCurrentOutputCell() {
    if (currentOutputCell != null
        && currentOutputCell.cellBytesConsumed() > RelayCell.HEADER_SIZE) {
      stream.waitForSendWindowAndDecrement();
      stream.getCircuit().sendRelayCell(currentOutputCell);
      bytesSent += (currentOutputCell.cellBytesConsumed() - RelayCell.HEADER_SIZE);
    }

    currentOutputCell =
        new RelayCellImpl(
            stream.getTargetNode(),
            stream.getCircuit().getCircuitId(),
            stream.getStreamId(),
            RelayCell.RELAY_DATA);
  }
 public synchronized void close() {
   if (isClosed) return;
   flush();
   isClosed = true;
   currentOutputCell = null;
   stream.close();
 }
  static {
    DEFAULT_SCHEME_MAP = new SchemeMap();

    Path.setDefaultSchemeMap(DEFAULT_SCHEME_MAP);

    FilePath pwd = new FilePath(null);
    PWD = pwd;
    setPwd(pwd);
    ENV_PWD.setGlobal(pwd);
    ENV_PWD.set(pwd);

    _localSchemeMap.setGlobal(DEFAULT_SCHEME_MAP);

    DEFAULT_SCHEME_MAP.put("file", pwd);

    DEFAULT_SCHEME_MAP.put("memory", new MemoryScheme());

    DEFAULT_SCHEME_MAP.put("jar", new JarScheme(null));
    /* XXX:
    DEFAULT_SCHEME_MAP.put("mailto",
     new MailtoPath(null, null, null, null));
    */
    DEFAULT_SCHEME_MAP.put("classpath", new ClasspathPath(null, "", ""));
    DEFAULT_SCHEME_MAP.put("http", new HttpPath("127.0.0.1", 0));
    DEFAULT_SCHEME_MAP.put("https", new HttpsPath("127.0.0.1", 0));
    // DEFAULT_SCHEME_MAP.put("hmux", new HmuxPath("127.0.0.1", 0));
    DEFAULT_SCHEME_MAP.put("tcp", new TcpPath(null, null, null, "127.0.0.1", 0));
    DEFAULT_SCHEME_MAP.put("tcps", new TcpsPath(null, null, null, "127.0.0.1", 0));
    // DEFAULT_SCHEME_MAP.put("log", new LogPath(null, "/", null, "/"));

    DEFAULT_SCHEME_MAP.put("merge", new MergePath());

    StreamImpl stdout = StdoutStream.create();
    StreamImpl stderr = StderrStream.create();
    DEFAULT_SCHEME_MAP.put("stdout", stdout.getPath());
    DEFAULT_SCHEME_MAP.put("stderr", stderr.getPath());
    VfsStream nullStream = new VfsStream(null, null);
    DEFAULT_SCHEME_MAP.put("null", new ConstPath(null, nullStream));
    DEFAULT_SCHEME_MAP.put("jndi", new JndiPath());

    DEFAULT_SCHEME_MAP.put("datastore", new DatastorePath("/"));

    /*
    DEFAULT_SCHEME_MAP.put("config", new ConfigPath());
    */
    DEFAULT_SCHEME_MAP.put("spy", new SpyScheme());
  }
 public String toString() {
   return "TorOutputStream stream=" + stream.getStreamId() + " node=" + stream.getTargetNode();
 }