"Too many open files" error on OpenSolaris 0906

Feature requests not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
sigxcpu
Posts: 2
Joined: Thu Dec 17, 2009 3:18 pm

"Too many open files" error on OpenSolaris 0906

Post by sigxcpu »

Hi,

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)
I've checked the files opened by transmission with pfiles and the usage is MUCH below assigned limit (about 10% file descriptors used), so this is a fake error somehow.

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;
}
tarr
Posts: 5
Joined: Wed Dec 02, 2009 9:44 am

Re: "Too many open files" error on OpenSolaris 0906

Post by tarr »

The 'Too many open files' is related to 32bit applications having just 256 filedescriptors available. Whatever you do regarding rlimit as long as libc is used. You can preload /usr/lib/extendedFILE.so.1 to get around that limitation or build it as a 64bit application. There is some solaris specific libc functions to enable extended file support without preloading, they can be found in the related man pages. But in general the easiest way is go 64bit.

http://developers.sun.com/solaris/artic ... o_256.html

Regarding EVENT_NOEVPORT, do you know if that is needed when building with the transmission-supplied libevent?

EDIT: It definitly feels like transmission works better without using solaris event ports, i.e. EVENT_NOEVPORT=1 set
sigxcpu
Posts: 2
Joined: Thu Dec 17, 2009 3:18 pm

Re: "Too many open files" error on OpenSolaris 0906

Post by sigxcpu »

Hi,

Thanks for the answer. The 64bit is not an option as this machine is a 32bit NAS (Thecus N5200 Pro).
I will try with the /usr/lib/extendedFILE.so.1 library preloaded and see what happens.

Anyway, the idea of having a known good file, before overwriting it still stands.

Regarding EVENT_NOEVPORT, that is read from the supplied transmission bundled libevent in third-party/libevent/evport.c, function evport_init().

EDIT: LD_PRELOADing the library seems to work. I've re-enabled error reporting in bencode.c but no errors are shown until now (they were appearing pretty fast after startup).
Post Reply