Package: gsm-utils
Version: 1.10-7
Severity: normal
Tags: patch

Hi there.

I'm using gsmlib over a Bluetooth RFCOMM serial device to talk to my
phone.  RFCOMM serial devices are a little touchy about being close()d
and immediately re-open()d - the open() succeeds, but other syscalls on 
the returned filehandle will fail with -EIO.  If a sleep(1) is inserted 
between the close() and open() then the problem goes away.  Inserting a 
sleep() /after/ the open() doesn't work, however long you sleep for - I 
reckon all other syscalls on the filehandle fail, and you need a new 
filehandle to proceed, but ICBW.  Presumably this is something to do 
with the previous Bluetooth connection being in the process of being 
torn down when we try to establish the new one, but why it stays broken 
for the lifetime of the filehandle escapes me.

gsmsmsstore manages to uncover this timing issue because it opens and
closes the device through iostreams to check it exists right before
opening it for serial IO.  The serial ioctls then fail, and gsmsmsstore
exits with an error.  For the benefit of Googlers, the message is:
  gsmsmsstore[ERROR]: clearing DTR failed (errno: 5/Input/output error)
This makes gsmsmsstore rather unusable with RFCOMM devices.

So, a patch is attached that uses gsm_util.cc's "isFile()" to test
for device existence instead, which uses stat() internally instead of 
open and close and therefore steps around the problem.  I think the 
file existence check was broken (exception was discarded) and rather 
inelegant, and is probably redundant (think we call isFile() later on 
pretty much everything), but anyway...

Cheers,

Isaac Wilcox

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-zak
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)

Versions of packages gsm-utils depends on:
ii  adduser                       3.77       Add and remove users and 
ii  libc6                         2.3.5-6    GNU C Library: Shared 
ii  libgcc1                       1:4.0.2-4  GCC support library
ii  libgsmme1c2                   1.10-7     GSM mobile phone access 
ii  libstdc++6                    4.0.2-4    The GNU Standard C++ 

gsm-utils recommends no packages.

-- no debconf information
--- gsmlib-1.10/apps/gsmsmsstore.cc.orig	2002-05-14 20:38:12.000000000 +0100
+++ gsmlib-1.10/apps/gsmsmsstore.cc	2005-11-21 15:46:15.000000000 +0000
@@ -292,19 +292,14 @@
         sourceStore = new SortedSMSStore(sourceMeTa->getSMSStore(storeName));
       }
       
-    // make sure destination file exists
+    // make sure destination file exists if specified
+    // Use isFile() for its exception-throwing properties, and discard
+    // return value cos we don't care (yet) whether it's a device or a
+    // regular file.
     if (destination != "")
-    {
-      try
-      {
-        ofstream f(destination.c_str(), ios::out | ios::app | ios::binary);
-      }
-      catch (exception)
-      {
-      }
-    }
+      isFile(destination);
 
-    // start accessing destination destination store or file
+    // start accessing destination store or file
     if (operation == CopyOp || operation == BackupOp || operation == AddOp ||
         operation == DeleteOp)
       if (destination == "-")

Reply via email to