-
Notifications
You must be signed in to change notification settings - Fork 607
AttachmentReader::read() returns ReadStatus::CLOSED if an AttachmentWriter has not been created yet #25
Comments
Hi Irvega, The behavior you are observing is the intended behavior. The SDS is designed such that you should create a writer before trying to read from the SDS, otherwise SDS will report CLOSED. At the Attachment layer, it looks like there is a potential race condition in the SDK. Have you observed a real problem here, or are you just reviewing the code? An SDS user needs to ensure that they create the writer before they try to read, but if you are writing a CapabilityAgent, you have no visibility or control over when the writer is created. In theory, a Directive might come in from AVS and have a delay before the attachment arrives, and if you tried to start reading in the mean time, it would appear that the attachment is closed. We will review the code further to confirm that this is an issue, and identify a fix in AttachmentManager which ensures that the writer exists before the AttachmentReader is returned. Ken |
Hi Ken, Thanks for the response. That potential race condition that you mention is actually possible and we have hit it. Our directive processing thread ( Thanks, |
Hi Luis, Thanks for confirming that you're seeing this race condition occur. Your workaround sounds viable, and I agree with your interpretation of the issue. We are working on a fix which will address this internally, so that you will be able to safely read without any possibility of a CLOSED return. Ken |
Hi Luis, We reviewed a couple of options here and settled on changing the behavior of SDS to treat a This change fixes the problem you are seeing. We will include this fix in a future release of the SDK, but if you would like to make the change in your local codebase now, change this line to read:
Note that this change will cause a failure in the SDS unit tests, which can be corrected by changing these two lines to read:
Thanks for pointing this issue out. |
Thanks Ken. We will make the appropriate changes on our side. |
Changes in this update - Added a getConfiguration() method to DirectiveHandlerInterface to register Capability Agents with Directive Sequencer. - Fix race condition with reading attachments before a writer exists. - Use of new Logging abstraction layer in modules - ADSL,AFML,ContextManager,AuthDelegate,AIP,KWD,Mediaplayer. - Added ACL stream processing with Pause and redrive. - Removed the dependency of ACL Library on Authdelegate. - Added and interface to allow ACL to Add/Remove ConnectionStatusObserverInterface. - Fixed compile errors in KittAi, DirectiveHandler and compiler warnings in AIP test. - Corrected formatting on the files. - Fixes for the following Github issues - #21 - #25
Hi Luis, Thanks. |
Hi, Once we've integrated the new drop and re-tested, I'll close. Thanks, |
Coming the issue for now, please re-open if the problem still exists. |
Now that
SharedDataStreams
exist and have provided the foundation for asynchronous read/write semantics forAttachments
, anAttachmentReader
can be created before its correspondingAttachmentWriter
. The user of the reader could callread()
before the writer exists. This will return aReadStatus::CLOSED
.In a non-blocking
AttachmentReader
, I would have expected it to returnReadStatus::OK_WOULDBLOCK
. When it's blocking, I would have expectedReadStatus::OK_TIMEDOUT
. In both cases, allowed the user of the API to decide what to do. The problem with it returningReadStatus::CLOSED
when a writer never existed is that you don't know if the writer is done unless you keep track in your code (for example, a boolean keeping track if it's the first time you've read).I am not necessarily saying that this is a bug if this is the design intent, but I want to get confirmation.
The text was updated successfully, but these errors were encountered: