Fix resource leak

This commit is contained in:
Chocobo1 2015-07-11 15:12:55 +08:00
parent bbe51268d3
commit c69e8805e9
1 changed files with 4 additions and 3 deletions

View File

@ -991,6 +991,7 @@ int main(int argc, char* argv[])
if (ret != buf.size()) if (ret != buf.size())
{ {
fprintf(stderr, "write returned: %d (expected %d)\n", int(ret), int(buf.size())); fprintf(stderr, "write returned: %d (expected %d)\n", int(ret), int(buf.size()));
fclose(f);
return 1; return 1;
} }
printf("wrote %s\n", torrent_name); printf("wrote %s\n", torrent_name);
@ -1024,7 +1025,7 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
tcp::endpoint ep(addr, destination_port); tcp::endpoint ep(addr, destination_port);
#if !defined __APPLE__ #if !defined __APPLE__
// apparently darwin doesn't seems to let you bind to // apparently darwin doesn't seems to let you bind to
// loopback on any other IP than 127.0.0.1 // loopback on any other IP than 127.0.0.1
@ -1065,7 +1066,7 @@ int main(int argc, char* argv[])
thread t1(boost::bind(&io_thread, &ios[0])); thread t1(boost::bind(&io_thread, &ios[0]));
thread t2(boost::bind(&io_thread, &ios[1])); thread t2(boost::bind(&io_thread, &ios[1]));
t1.join(); t1.join();
t2.join(); t2.join();
@ -1073,7 +1074,7 @@ int main(int argc, char* argv[])
float down = 0.f; float down = 0.f;
boost::uint64_t total_sent = 0; boost::uint64_t total_sent = 0;
boost::uint64_t total_received = 0; boost::uint64_t total_received = 0;
for (std::vector<peer_conn*>::iterator i = conns.begin() for (std::vector<peer_conn*>::iterator i = conns.begin()
, end(conns.end()); i != end; ++i) , end(conns.end()); i != end; ++i)
{ {