gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sm_block final(?) fix (patch)


From: Osma Suominen
Subject: sm_block final(?) fix (patch)
Date: Fri, 28 Feb 2003 01:04:50 +0200 (EET)

Hi,

I submitted some days ago a oneline patch for __sm_block_timeout()
that was supposed to tweak its retry behaviour a bit so that it would
not expect an ack if it was called without sending a message.

Now it turned out there was another problem in the later loop, that also
caused bad behaviour in the aforementioned case.

Here is a patch that causes sm_block not to
a) wait for an ack in case no message was sent (as before, but nicer)
b) erroneously report timeout if a message was not sent and the phone
   does not reply within 100ms

I hope this fix is final. It should not cause any problems for other
drivers, but do test it nevertheless.

-Osma

Index: gsm-statemachine.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/gsm-statemachine.c,v
retrieving revision 1.45
diff -u -r1.45 gsm-statemachine.c
--- gsm-statemachine.c  26 Feb 2003 00:15:47 -0000      1.45
+++ gsm-statemachine.c  27 Feb 2003 22:58:11 -0000
@@ -216,10 +216,11 @@
 static gn_error __sm_block_timeout(int waitfor, int t, gn_data *data, struct 
gn_statemachine *state)
 {
        int retry;
-       gn_state s = GN_SM_Startup;
+       gn_state s;
        gn_error err;
        struct timeval now, next, timeout;

+       s = state->current_state;
        timeout.tv_sec = 3;
        timeout.tv_usec = 0;
        gettimeofday(&now, NULL);
@@ -227,6 +228,9 @@
                err = sm_wait_for(waitfor, data, state);
                if (err != GN_ERR_NONE) return err;

+               /* if no packet has been sent, don't wait for ack */
+               if (s == GN_SM_Initialised) break;
+
                timeradd(&now, &timeout, &next);
                do {
                        s = gn_sm_loop(1, state);  /* Timeout=100ms */
@@ -248,7 +252,7 @@
        do {
                s = gn_sm_loop(1, state);  /* Timeout=100ms */
                gettimeofday(&now, NULL);
-       } while (timercmp(&next, &now, >) && (s == GN_SM_WaitingForResponse));
+       } while (timercmp(&next, &now, >) && (s != GN_SM_ResponseReceived));

        if (s == GN_SM_ResponseReceived) return sm_error_get(waitfor, state);


-- 
*** Osma Suominen *** address@hidden *** http://www.iki.fi/ozone/ ***




reply via email to

[Prev in Thread] Current Thread [Next in Thread]