On Fri, March 2, 2012 12:21, Tom Weber wrote: > The problem is that you as an application developer don't control the context > in which the callback is called. > > 1) You might want to disconnect and free the session, but you can't do that > since you have to return to a libssh2_session_ routine, which expects the > session to be valid. > > 2) You might want to process the event later, and then you need an additional > mechanism to save the event. > > 3) During which function call, and from which thread, can we count on the > callback being called? We must know that exactly, to handle things like > mutexes and resource ownership correctly. (Preferably the callback pointer > should be provided at the function call and not saved, to make this more > clear.)
4) It's often unclear which functions are safe to call from a callback. (This is point 3 in reverse.) For instance, if I receive channel data in a callback, is it safe to send a reply from within the callback? To send data back on another channel? To change some session parameter? To start a new channel? Etc... -- Best regards, Tom Weber Cryptzone Group AB _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel