int swift::Open (const char* filename, const Sha1Hash& hash) {
FileTransfer* ft = new FileTransfer(filename, hash);
- int fdes = ft->file().file_descriptor();
- if (fdes>0) {
+ if (ft && ft->file().file_descriptor()) {
/*if (FileTransfer::files.size()<fdes) // FIXME duplication
FileTransfer::files.resize(fdes);
if (Channel::tracker!=Address())
new Channel(ft);
- return fdes;
+ return ft->file().file_descriptor();
} else {
- delete ft;
+ if (ft)
+ delete ft;
return -1;
}
}
(channels are cheap and easily recycled)
<li> a datagram must contain either the receiving
channel id (scrambled) or the root hash
- <li> initially, the control structure (p2tp_channel)
- is mostly zeroed; intialization happens as
- conversation progresses
</ul>
<b>Note:</b>
*/