You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2020/11/16 20:04:54 UTC

[GitHub] [incubator-daffodil] stevedlawrence commented on pull request #457: Correctly detect zero length status for "dead" DataOutputStreams

stevedlawrence commented on pull request #457:
URL: https://github.com/apache/incubator-daffodil/pull/457#issuecomment-728294084


   Say we have a direct DOS that is immediately followed by some buffered DOS's, let's call them DOS A and DOS B. The way the postifx suspension stuff works is it depends on some previous DOSs and cannot resolve until their ``zeroLengthStatus`` is determined. Let's assume our postfix suspension only cares about the zeroLengthStatus of the buffered DOS A.
   
   Now let's assume DOS B is finished via a call to ``setFinished``. Because DOS B is not direct, nothing happens except setting its state to Finished.
   
   Now let's assume DOS A is finished via a call to ``setFinished``. Because DOS A is not direct, nothing happens except setting its state to Finished.
   
   Let's also assume at this point nothing asks for the zeroLengthStatus of DOS A. So if nothing wrote to DOS A at this point, we can assume DOS A is a ``Zero`` zeroLengthStatus. But that isn't set yet.
   
   Now let's assume the Direct DOS is finished via a call to ``setFinished``. Because it is direct and it's finished, we then deliver the content of A to the OutputStream in our DirectDOS, and the A DOS becomes the new direct DOS. The state of the old direct DOS is set to "Uninitialized", i.e. ``isDead == true``. Because DOS B is also finished, we can deliver the contents of B to the new direct DOS (which is DOS A). Now DOS A is marked as uninitialized, ``isDead == true``, and B becomes the new direct DOS.
   
   So at this point we have two "dead" DOS's (the original direct DOS and DOS A) and DOS B is now the direct DOS.
   
   But there is still a suspension that needs to know the zeroLengthStatus of this dead DOS A so that it can determine if the postfix separator should be unparsed. When the suspension unsuspends (whenever that may be), it will ask for the zeroLengthStatus of this dead DOS and we must give it an answer. Even though this DOS is dead, it still is needed to provide zero length information.
   
   So the crux of the issue is that a DOS that a suspension depends on could be finished, made direct, and then made dead, all before the suspension that needs information about that DOS unsuspends and asks for the zeroLengthStatus. Fortunately, the logic for finished vs dead is exactly the same. Suspensions don't care.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org