Coder Social home page Coder Social logo

Comments (5)

harrisonturton avatar harrisonturton commented on June 10, 2024

I dig some more digging, and found some more information:

Due to limitations in the C API, the Client and it's associated Network can only be initialized and run once per the life of a process. Generally the foundationdb::init function will be enough to initialize the Client. See foundationdb::default_api and foundationdb::builder for more configuration options of the Fdb Client.

From here.

Is this why we must drop it explicitly? Something to do with "it's associated Network can only be initialised and run once per the life of a process."

from foundationdb-rs.

PierreZ avatar PierreZ commented on June 10, 2024

👋

I love that this crate exists. Thanks for all your hard work heart

First of all, thank you for the kind words ❤️

Which leaves me with two questions:

1. Doesn't Rust call `drop` automatically when `network` goes out of scope - why must I call it manually?

2. What happens if my code panics before calling `drop`?

I think @Speedy37 will have a far better answer than me, as we worked heavily on making boot safe (5d4954a, 8725b6e, 7b5d67e, c53f7f6) but had to revert in the end.

If you could help me understand this better, I'm happy to raise a PR updating the documentation with a deeper description of the motivations and usage recommendations.

That would be awesome to clarify that indeed.

from foundationdb-rs.

Speedy37 avatar Speedy37 commented on June 10, 2024

I tried multiple times to make boot safe but always found a way to break it.

Trying to boot multiples times is already checked and would result in a panic (no undefined behavior here).
The unsafe part is due to undefined behavior occurring if fdb_stop_network() is not called before main exits

You must call this function and wait for fdb_run_network() to return before allowing your program to exit, or else the behavior is undefined.

See Clikengo/foundationdb-rs#202 for details

ie.

  • forget(network)
  • process::exit triggered by another thread
  • ...

from foundationdb-rs.

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.