[Bug 163050] Strigi indexing of large/unbounded files causes KFileMetaInfo to freeze.

Jos van den Oever jos at vandenoever.info
Fri Jun 6 21:59:03 CEST 2008


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=163050         




------- Additional Comments From jos vandenoever info  2008-06-06 21:59 -------
For Strigi, the problem of files like /dev/null has been solved in fileinputstream.cpp:66:
    // determine file size. if the stream is not seekable, the size will be -1
    if (fseeko(file, 0, SEEK_END) == -1) {
        m_size = -1;
    } else {
        m_size = ftello(file);
        fseeko(file, 0, SEEK_SET);
        // if the file has size 0, make sure that it's really empty
        // this is useful for filesystems like /proc that report files as size 0
        // for files that do contain content
        if (m_size == 0) {
            char dummy[1];
            size_t n = fread(dummy, 1, 1, file);
            if (n == 1) {
                m_size = -1;
                fseeko(file, 0, SEEK_SET);
            } else {
                fclose(file);
                file = 0;
                return;
            }
        }
    }

In kdelibs, a stream is created from a QIODevice. We need a way to tell if the size of the stream is really finite. /dev/null is size 0, but you can keep reading from it. If the stream is an infinite stream, like /dev/null is, but reports that is size zero, the underlying QIODevice should be closed and the BufferedStream should make 0 bytes available.


More information about the Kdelibs-bugs mailing list