Package: transmission
Version: 2.52-3+nmu1
Severity: important
Tags: patch

Hi! 

Current stable version of transmission has a grave bug that makes it almost 
unusable: From time to time one or other downlading task pauses with "Bad file 
descriptor error" error. 

This bug is described in upstream bug tracker 
https://trac.transmissionbt.com/ticket/4147

This bug were solved in released version 2.82 (it will soon migrate to testing 
so there would be no problem).

I've ported the patch that fixes this problem 
https://trac.transmissionbt.com/changeset/14147 to fit for 2.52 (nothing 
serious, just remove or add some spaces) 
If works for me well for several weeks with no problems.

Here I attach the patch, and I would suggest to apply it in security fix, as 
without it transmission requires constant resuming of auto paused tasks and 
can't be normally used.


-- System Information:
Debian Release: 7.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/4 CPU cores)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages transmission depends on:
ii  transmission-cli     2.52-3+nmu1
ii  transmission-common  2.52-3+nmu1
ii  transmission-gtk     2.52-3+nmu1

transmission recommends no packages.

transmission suggests no packages.

-- no debconf information
Description: Fix of "Bad file descriptor" error
Origin: https://trac.transmissionbt.com/changeset/14147
Bug: https://trac.transmissionbt.com/ticket/4147

--- transmission-2.52.orig/libtransmission/fdlimit.c
+++ transmission-2.52/libtransmission/fdlimit.c
@@ -350,6 +350,7 @@ cached_file_open( struct tr_cached_file
     int flags;
     struct stat sb;
     bool alreadyExisted;
+    bool resize_needed;
 
     /* create subfolders, if any */
     if( writable )
@@ -364,9 +365,9 @@ cached_file_open( struct tr_cached_file
         tr_free( dir );
     }
 
-    alreadyExisted = !stat( filename, &sb ) && S_ISREG( sb.st_mode );
+     alreadyExisted = !stat (filename, &sb) && S_ISREG (sb.st_mode);
 
-    if( writable && !alreadyExisted && ( allocation == TR_PREALLOCATE_FULL ) )
+     if (writable && !alreadyExisted && (allocation == TR_PREALLOCATE_FULL))
         if( preallocate_file_full( filename, file_size ) )
             tr_dbg( "Preallocated file \"%s\"", filename );
 
@@ -388,17 +389,14 @@ cached_file_open( struct tr_cached_file
      * http://trac.transmissionbt.com/ticket/2228
      * https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/318249
      */
-    if( alreadyExisted && ( file_size < (uint64_t)sb.st_size ) )
+    if (resize_needed && (ftruncate (o->fd, file_size) == -1))
     {
-        if( ftruncate( o->fd, file_size ) == -1 )
-        {
-            const int err = errno;
-            tr_err( _( "Couldn't truncate \"%1$s\": %2$s" ), filename, tr_strerror( err ) );
-            return err;
-        }
+      const int err = errno;
+      tr_logAddError (_("Couldn't truncate \"%1$s\": %2$s"), filename, tr_strerror (err));
+      return err;
     }
 
-    if( writable && !alreadyExisted && ( allocation == TR_PREALLOCATE_SPARSE ) )
+    if (writable && !alreadyExisted && (allocation == TR_PREALLOCATE_SPARSE))
         preallocate_file_sparse( o->fd, file_size );
 
     /* Many (most?) clients request blocks in ascending order,

Reply via email to