callers of ca_add_fd_registration might not always receive select wakeup

Bug #541387 reported by Jeff Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Medium
Jeff Hill

Bug Description

During regression testing against an asynchronous variable in the portable server I noticed that the test hung in the fdManagerVerify. There is an esoteric feature in ca client library where the application can watch the ca client librarys file descriptors and call ca_poll (ca_pend_event) when there is activity in the client librarys sockets. The following scenario wasnt working if the service was slower than usual completing the connect sequence for a channel.

Additional information:

    status = ca_add_fd_registration ( fdRegCB, mgrCtx );
    assert ( status == ECA_NORMAL );

    status = ca_create_channel ( pName, 0, 0, 0, & newChan );
    assert ( status == ECA_NORMAL );

    while ( ca_state ( newChan ) != cs_conn ) {
        tmo.tv_sec = 6000;
        tmo.tv_usec = 0;
        status = fdmgr_pend_event ( mgrCtx, & tmo );
        assert ( status >= 0 );
    }

Original Mantis Bug: mantis-361
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=361

Tags: ca 3.14
Revision history for this message
Jeff Hill (johill-lanl) wrote :

committed this fix

cvs diff -wb (in directory C:\hill\R3.14.dll_hell_fix\epics\base\src\ca\)
? Edit1.TXT
? RCa01512
? tst.cpp
Index: ca_client_context.cpp
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/ca/ca_client_context.cpp,v
retrieving revision 1.9.2.23
diff -u -b -w -b -r1.9.2.23 ca_client_context.cpp
--- ca_client_context.cpp 23 Aug 2007 17:46:22 -0000 1.9.2.23
+++ ca_client_context.cpp 21 Aug 2009 00:46:12 -0000
@@ -253,6 +253,11 @@
     this->fdRegFunc = pFunc;
     this->fdRegArg = pArg;
     this->fdRegFuncNeedsToBeCalled = true;
+ if ( pFunc ) {
+ // the receive thread might already be blocking
+ // w/o having sent the wakeup message
+ this->_sendWakeupMsg ();
+ }
 // should block here until releated callback in progress completes
 }

@@ -557,11 +562,11 @@
                         0, & tmpAddr.sa, & addrSize );
             } while ( status > 0 );
         }
- this->noWakeupSincePend = true;
         while ( this->callbackThreadsPending > 0 ) {
             epicsGuardRelease < epicsMutex > unguard ( guard );
             this->callbackThreadActivityComplete.wait ( 30.0 );
         }
+ this->noWakeupSincePend = true;
     }

     double elapsed = epicsTime::getCurrent() - current;
@@ -613,6 +618,13 @@
             }
         }
         if ( sendNeeded ) {
+ _sendWakeupMsg ();
+ }
+ }
+}
+
+void ca_client_context :: _sendWakeupMsg ()
+{
             // send short udp message to wake up a file descriptor manager
             // when a message arrives
             osiSockAddr tmpAddr;
@@ -623,8 +635,6 @@
             sendto ( this->sock, & buf, sizeof ( buf ),
                     0, & tmpAddr.sa, sizeof ( tmpAddr.sa ) );
         }
- }
-}

 void ca_client_context::callbackProcessingCompleteNotify ()
 {
Index: oldAccess.h
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/ca/oldAccess.h,v
retrieving revision 1.47.2.17
diff -u -b -w -b -r1.47.2.17 oldAccess.h
--- oldAccess.h 23 Aug 2007 17:46:24 -0000 1.47.2.17
+++ oldAccess.h 21 Aug 2009 00:46:12 -0000
@@ -404,6 +404,7 @@
     void callbackProcessingCompleteNotify ();
     cacContext & createNetworkContext (
         epicsMutex & mutualExclusion, epicsMutex & callbackControl );
+ void _sendWakeupMsg ();

  ca_client_context ( const ca_client_context & );
  ca_client_context & operator = ( const ca_client_context & );

***** CVS exited normally with code 1 *****

Revision history for this message
Jeff Hill (johill-lanl) wrote :

fixed in R3.14.11

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.11 released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.