(trukn libT) call tr_close_file() instead of close() after saving a benc file to disk

This commit is contained in:
Charles Kerr 2010-09-29 02:38:14 +00:00
parent ea96b3ceff
commit 865d9d7a34
1 changed files with 4 additions and 3 deletions

View File

@ -27,7 +27,7 @@
#include <sys/types.h> /* stat() */
#include <sys/stat.h> /* stat() */
#include <locale.h>
#include <unistd.h> /* stat(), close() */
#include <unistd.h> /* stat() */
#include <event.h> /* struct evbuffer */
@ -35,6 +35,7 @@
#include "transmission.h"
#include "bencode.h"
#include "fdlimit.h" /* tr_close_file() */
#include "json.h"
#include "list.h"
#include "platform.h" /* TR_PATH_MAX */
@ -1682,7 +1683,7 @@ tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
if( write( fd, str, len ) == (ssize_t)len )
{
tr_fsync( fd );
close( fd );
tr_close_file( fd );
if( !unlink( filename ) || ( errno == ENOENT ) )
{
@ -1710,7 +1711,7 @@ tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
{
err = errno;
tr_err( _( "Couldn't save temporary file \"%1$s\": %2$s" ), tmp, tr_strerror( err ) );
close( fd );
tr_close_file( fd );
unlink( tmp );
}