next up previous contents index
Next: External Keys Up: Usage Rules Previous: Usage Rules

Map Modifications During mapForEach

 

It is no longer permissible to directly remove the ``current'' entry in a mapForEach callback function, as it was in x-kernel version 3.2. When adapting a version 3.2 protocol, care should be take to remove such illegal map modifications.

Illegal map modifications often appear in timeout handlers closing active sessions. Such code can be fixed easily because it is customary to save the binding of an active session in the

binding field of the Sessn and for functions that close sessions to check this field and perform a mapRemoveKey only if it is non-zero. The fix is to modify the timeout handler to (a) reset binding to zero, (b) call the session-closing function, and (c) return the flag MFE_REMOVE in addition to any other flags that may have been returned by the mapForEach callback function. This ensures that the map entry for the active session that is being closed remains in the map until the mapForEach callback function returns.



Larry Peterson
Wed Jan 10 10:40:08 MST 1996