Comments (8)
Hi,
if I understand it correctly, the appended patch could fix it, could you please try it?
Regards,
Michal
from libnetconf2.
This would not work since pthread_cond_timedwait(session->opts.server.ch_cond, ...) does not always exit immediately when the associated signal is called (in nc_session_free), thus allowing the destroy to happen while still in pthread_cond_timedwait(session->opts.server.ch_cond, ...). I have verified this with print statements at the point where your patch is located.
The exit condition wont be executed if the thread is still stuck in the pthread_cond_timedwait
from libnetconf2.
Hi,
that makes sense. Could you please try it now, with the latest libnetconf2? Just a more polished version of your patch (I hope) so not a perfect solution but it should handle all systems with reasonable synchronization.
Regards,
Michal
from libnetconf2.
I like the fact that it only destroys things in the thread, however...
- if nc_session_free is called after the closing test but before the end of the loop, things will never get freed.
- a good exit (non failure) now returns 1 instead of 0
- its probably not necessary to wait for thread closure at the end at all as the thread will close things automatically. As long it is disassociated from the registry, it doesn't matter. May be another race there but I suspect not.
- not sure if CALLHOME flag locking is an issue as its not cleared on exit of loop at the end of the loop.
- CALLHOME shoudl be cleared before the cond var and mutex are destroyed as the nc_session_free does not need to signal because it is already exiting before the free was called.
suggest 1 cleanup handler, returns 0 if CLOSING was true, clear CALLHOME FLAG first and optionally dont wait for thread closure at the end of nc_session_free because I think (not sure) its unnecessary you would have more deep knowledge on the guts in this respect. May be safer to wait as you are currently doing if not sure of the consequences.
from libnetconf2.
Hi,
I have rewritten it again, hopefully for the last time, what do you think about it now?
Regards,
Michal
from libnetconf2.
Sorry for the delay in responding. One last major issue as I see it.
- The mutex could still be locked when it is destroyed. This would be a bad thing. It needs a lock/unlock before the mutex/condvar are destroyed, just in case the thread is interrupted while the mutex is held.
- In nc_server_ch_client_thread_session_cond_wait, good return is now 1 and bad is -1. Previously it was good=1 and bad = 0 (or -1 if it didnt allocate a session). Is this intentional?
Destroying the mutex in free only is also good but you have to make sure its not being used any more in the thread.
from libnetconf2.
Hi,
fine, any other corner cases you would like covered?
Return value meaning changed slightly and it was intentional but I don't really see good/bad returns. -1
is returned on some unexpected libc function error, 1
is returned when the CH client configuration of the session was removed and 0
on any other return (basically session terminated for whatever reason, close-sesion, timeout, ...). I decided new session will not be established on -1
and 1
returns (I was thinking about -1
, nothing would prevent retrying to establish a new session but then again, a function returned a fatal error so it would most likely always fail with an error).
Regards,
Michal
from libnetconf2.
Yes that will fix the issue.
Thanks for your patience. This is now a very robust solution for this functionality.
from libnetconf2.
Related Issues (20)
- Missing dependencies in package detection HOT 1
- Unable to build libnetconf2 : make: *** [Makefile:100: install] Error 1 HOT 1
- I am trying to compile libssh-0.10.5 with openssl-3.2.1 getting the folowing errors while compiling please help me on that HOT 8
- compile error HOT 4
- Occasional assert seen when notification thread shutting down HOT 5
- Segfault in nc_accept when password is not defined HOT 3
- Session context with yang-library instance of mount point HOT 27
- Build fails with LTO HOT 1
- Failed to run libnetconf2 example HOT 5
- ERR: Received an invalid message (Node "next-update-at" not found as a child of "edit-config" node.). HOT 6
- Getting "libnetconf ERROR: When condition is accessing its own conditional node children." HOT 20
- `nc_set_print_clb_session` is not really a per-session callback HOT 2
- poll error (Success) HOT 4
- libnetconf2 make issue HOT 1
- Delucidation on nc_recv_notif_dispatch HOT 2
- [Query] Netconf notification not being received by Client Application HOT 2
- Building failure HOT 1
- Authenticate users with central user management HOT 4
- Segfault when sending malformed XML HOT 7
- Not read all modules from server via get-schema HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libnetconf2.