public void fileDescriptorReceived(DownloadConnection source, FileDescriptor fd) throws IOException { if (this.fd != null) { if (T.t) { T.info("Already has FD. Ignore the new one and start download for this connection."); } if (T.t) { T.ass(source.readyToStartDownload(), "Not ready to start download?"); } if (needsMoreDownloadConnections()) { source.startDownloadingBlock(); } return; } if (T.t) { T.debug("Received file descriptor " + fd); } this.fd = fd; setState(State.DOWNLOADING); ArrayList<DownloadConnection> al = new ArrayList<DownloadConnection>(); for (DownloadConnection c : connections.values()) { al.add(c); } for (DownloadConnection c : al) { if (c.readyToStartDownload() && needsMoreDownloadConnections()) { c.startDownloadingBlock(); } } }