I've compiled transmission-daemon on OpenSolaris 0906 and I have the following problems:
1. EVENT_NOEVPORT must be set, otherwise everything is stalled. This is OK and it is fixed by setting up the environment variable.
2. Randomly, transmission received "Too many open files" error in bencode.c:1546 (it is a fopen() ). This wouldn't be a problem, but the "truncate" part of the fopen() succeeds and
the .resume files contents is erased. In case of reboot or restart, all the torrents having a size of 0 on the .resume files are rechecked, this taking a lot of time when many torrents with big sizes are present in the seed list.
Below is the error:
Code: Select all
Dec 17 02:12:52 Storage transmission-daemon: [ID 372733 daemon.error] Couldn't open "<some torrent name...>.resume": Too many open files (bencode.c:1546)
Anyway, for others having this problem, I've patched the function tr_bencToFile() as follows. This will ensure that a temporary file gets created and, if opening was ok (not checking for writing succes, though) rename it to the original .resume file. I've also inhibited error writing to the syslog, because I don't want to ignore daemon.error class in "dmesg" and Transmission fills it with its "Too many open files" error.
@Developers: maybe you can import the .tmp file idea in the main program, at least for ensuring overwrite on succesful write only.
Code: Select all
int
tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
{
int err = 0;
char tmp_filename[2048];
sprintf(tmp_filename, "%s.tmp", filename);
FILE * fp = fopen( tmp_filename, "wb+" );
if( fp == NULL )
{
err = errno;
//tr_err( _( "Couldn't open \"%1$s\": %2$s" ),
// filename, tr_strerror( errno ) );
}
else
{
int len;
char * str = tr_bencToStr( top, mode, &len );
if( fwrite( str, 1, len, fp ) == (size_t)len )
tr_dbg( "tr_bencToFile saved \"%s\"", filename );
else {
err = errno;
tr_err( _( "Couldn't save file \"%1$s\": %2$s" ), filename, tr_strerror( errno ) );
}
tr_free( str );
fclose( fp );
unlink(filename);
rename(tmp_filename, filename);
}
return err;
}