Mercurial > hg > openttd
changeset 15069:57c380effe21 draft
(svn r19695) -Fix: leaking a file descriptor
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 22 Apr 2010 18:34:45 +0000 |
parents | 67e618b529da |
children | 2c87e67e0fbf |
files | src/network/network_server.cpp |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -322,7 +322,7 @@ * nothing */ - static FILE *file_pointer; + static FILE *file_pointer = NULL; static uint sent_packets; // How many packets we did send succecfully last time if (cs->status < STATUS_AUTHORIZED) { @@ -337,9 +337,12 @@ /* Make a dump of the current game */ if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) usererror("network savedump failed"); + if (file_pointer != NULL) fclose(file_pointer); + file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR); + if (file_pointer == NULL) usererror("network savedump failed - could not open just saved dump"); + fseek(file_pointer, 0, SEEK_END); - if (ftell(file_pointer) == 0) usererror("network savedump failed - zero sized savegame?"); /* Now send the _frame_counter and how many packets are coming */ @@ -382,6 +385,7 @@ * to send it is ready (maybe that happens like never ;)) */ cs->status = STATUS_DONE_MAP; fclose(file_pointer); + file_pointer = NULL; NetworkClientSocket *new_cs; bool new_map_client = false;