Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2016-03-08
17:02 • Closed ticket [bbc304f61a]: reflected watch race condition plus 7 other chan... artifact: 69bc0626e2 user: dgp
15:55
[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First h... check-in: 3ed434c670 user: dgp tags: trunk
15:52
[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First h... check-in: e4f95d6178 user: dgp tags: core-8-5-branch
15:50
[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First h... check-in: f2a6351600 user: dgp tags: core-8-6-branch
07:24 • Ticket [bbc304f61a] reflected watch race condition status still Open with 3 ... artifact: ae7706cd11 user: aku
2016-03-02
15:30 • Ticket [bbc304f61a]: 3 changes artifact: 3f05ebc71b user: dgp
15:29
[bbc304f61a] Proposed fix for reflected watch race condition. closed check-in: 5057f650ba user: dgp tags: bug-bbc304f61a
15:28 • Ticket [bbc304f61a] reflected watch race condition status still Open with 3 ... artifact: afa0f1b8f2 user: dgp
15:28 • New ticket [bbc304f61a]. artifact: 7bc972ba5f user: dgp

reflected watch race condition

Closed / Fixedbbc304f61a08d9e781bc786896b74d5f13defe87Created 11 years agoUpdated 11 years ago
Descriptionplain2016-03-02 15:28:32
Very occasionally when running the test suite I will
see ioCmd.test report an error:

  tried to post events channel "rc0" is not interested in

I looked into this and it is due to the multi-thread
ReflectWatch() breaking up its function into parts,
and having the possibility of servicing an event
in between the parts, when the channel has changed
its interest mask, but the Watch command has not
yet been invoked.

I believe the proper fix is to tie the two changes
together so that from the perspective of event
servicing, the watch operation is atomic.

Unfortunately since the issue is timing specific and
hard to control in a testable way, this is somewhat
a matter of speculation.  A careful review is in order
at least.
Referenced by4
  • 3ed434c670[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First half in 1 thread, second in another). When this is allowed to happen, false alarm errors from [chan postevent] are the result when timing is unlucky. See test iocmd.tf-24.17.bug3522560 . check-in2016-03-08 15:55:51
  • e4f95d6178[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First half in 1 thread, second in another). When this is allowed to happen, false alarm errors from [chan postevent] are the result when timing is unlucky. check-in2016-03-08 15:52:23
  • f2a6351600[bbc304f61a] Avoid event handling when reflected channel has a watch change half-completed. (First half in 1 thread, second in another). When this is allowed to happen, false alarm errors from [chan postevent] are the result when timing is unlucky. See test iocmd.tf-24.17.bug3522560 . check-in2016-03-08 15:50:37
  • 5057f650ba[bbc304f61a] Proposed fix for reflected watch race condition. check-in2016-03-02 15:29:48
dgp Ticket [bbc304f61a]: 3 changes [History diff]2016-03-02 15:28:51
dgpplain2016-03-02 15:30:21
Proposed fix committed to a branch.
akuplain2016-03-08 07:24:10
Having read the ticket description, and the looked at the proposed fix I 
believe that this change is ok.

In essence you are moving the update of the interest mask to the last possible 
point before the script callback is invoked, and for the multi-threaded case 
this means that the update is changed to always happen in the handler thread. 
Making the servicing of events between mask update and use of the callback 
impossible.

That looks to be a sensible solution to me.

The only thing I would change is the // used to disable the old location. That 
I would simply remove completely.
dgpplain2016-03-08 17:02:36
fixed on all branches
Log in (anonymous is fine) to add a comment.