Hi all,

thanks to the report of David Dekert @Pengutronix, I was able to identify and fix a bug in RTcfg (any RTnet version). A race in the client state machine may prevent a successful handshake between a fast server and slow clients.

Attached is a patch to fix this and two other potential issues of the same type. It applies to 0.7.1 and the current CVS.

Have a nice weekend,
Jan
Index: rtcfg/rtcfg_client_event.c
===================================================================
RCS file: /cvsroot/rtnet/rtnet/rtcfg/rtcfg_client_event.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- rtcfg/rtcfg_client_event.c  4 Oct 2004 21:39:36 -0000       1.2
+++ rtcfg/rtcfg_client_event.c  8 Oct 2004 14:40:20 -0000       1.3
@@ -114,14 +114,14 @@ int rtcfg_main_state_client_1(int ifinde
             if (cmd_event->args.announce.burstrate < rtcfg_dev->burstrate)
                 rtcfg_dev->burstrate = cmd_event->args.announce.burstrate;
 
+            rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ANNOUNCED);
+
             ret = rtcfg_send_announce_new(ifindex);
             if (ret < 0) {
                 rtos_res_unlock(&rtcfg_dev->dev_lock);
                 return ret;
             }
 
-            rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ANNOUNCED);
-
             rtos_res_unlock(&rtcfg_dev->dev_lock);
 
             return -CALL_PENDING;
@@ -371,11 +371,12 @@ int rtcfg_main_state_client_2(int ifinde
             else
                 rtcfg_queue_blocking_call(ifindex, call);
 
+            rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_READY);
+
             if ((rtcfg_dev->flags & RTCFG_FLAG_READY) == 0) {
                 rtcfg_dev->flags |= RTCFG_FLAG_READY;
                 rtcfg_send_ready(ifindex);
             }
-            rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_READY);
 
             rtos_res_unlock(&rtcfg_dev->dev_lock);
 
@@ -851,8 +852,6 @@ static void rtcfg_client_recv_stage_2_cf
         if (rtcfg_dev->stations_found == rtcfg_dev->other_stations)
             rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ALL_KNOWN);
     } else {
-        rtcfg_send_ack(ifindex);
-
         if (rtcfg_dev->stations_found == rtcfg_dev->other_stations) {
             rtcfg_complete_cmd(ifindex, RTCFG_CMD_ANNOUNCE, 0);
 
@@ -861,6 +860,8 @@ static void rtcfg_client_recv_stage_2_cf
                 RTCFG_MAIN_CLIENT_READY : RTCFG_MAIN_CLIENT_2);
         } else
             rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ALL_FRAMES);
+
+        rtcfg_send_ack(ifindex);
     }
 
     rtos_res_unlock(&rtcfg_dev->dev_lock);

Reply via email to