php / pecl-networking-ssh2

Bindings for the libssh2 library
http://pecl.php.net/package/ssh2
Other
51 stars 58 forks source link

Added explicit ssh2_disconnect function #12

Closed credomane closed 8 years ago

credomane commented 8 years ago

Converted space indentations to tabs for formatting consistency.

credomane commented 8 years ago

Github broke right as I updated this pull request. So I'm probably gonna have to close this one too. I have another commit that went through to my branch for this PR but Github broke at that exact moment and the commit isn't appearing here in the PR. No clue how to fix that without, yet, another PR. Seems they were processing a backlog from the downtime a little while ago. My fixed commit is in the pr now.

I rediscovered my segfault issue when I explicitly call php_ssh2_session_dtor. This cleans up the c code for the ssh2 session but NOT the references in the zend engine. This leads to segfaults when php exits and has to clean up all variables in the zend engine. Also causes segfaults if you call ssh2_disconnect() twice with the exact same variable.

I switched to calling zend_list_close() to have the zend engine clean up it's references which triggers a call to php_ssh2_session_dtor if needed. This prevents segfaults in every case I could think of to try and properly terminates the ssh session when ssh2_disconnect is called.