Coder Social home page Coder Social logo

Comments (4)

rdoeffinger avatar rdoeffinger commented on June 12, 2024

But that is exactly the purpose of the non_blocking_adapter?
When a nonblocking sink returns 0 it should mean to try again later, and that's what it does.
In case if a permanent error, the sink must in fact return -1. I've not found that documented, but the code seems clear and consistent about this...
So why does the sink not return -1? If it can't know it's broken there is nothing that can be done really, since it's not possible to detect something is wrong.

from iostreams.

grapland0 avatar grapland0 commented on June 12, 2024

According to https://www.boost.org/doc/libs/1_76_0/libs/iostreams/doc/functions/write.html , iostreams::write simply returns t.rdbuf()->sputn(s, n) in this case. sputn can only return zero or greater, which looks like not being able to exit at any write error.

To detect whether the failure is permanent, do you think it should also check the fail/bad bit?

from iostreams.

rdoeffinger avatar rdoeffinger commented on June 12, 2024

It's a bit hard to say without knowing why the sink device would become "broken" and how it is designed to report that.
It could throw an exception when it breaks.
Or it could signal it via pubsync() returning -1, which maybe should be called if the write unexpectedly returns 0?
Though I am not sure if the combination of streambuf and non-blocking is making sense in the first place.

from iostreams.

rdoeffinger avatar rdoeffinger commented on June 12, 2024

Looking at this again, https://www.boost.org/doc/libs/1_76_0/libs/iostreams/doc/guide/exceptions.html suggests that exceptions should be used to report errors.
However iostream's own file_sink/source report read errors with -1 and write errors not at all.
Does anyone have any idea/suggestion how this kind of issue could be fixed?
E.g. full disk currently results in endless loop consuming 100% CPU.

from iostreams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.