vendor/libgit2/src/transports/ssh.c in rugged-0.26.0b5 vs vendor/libgit2/src/transports/ssh.c in rugged-0.26.0
- old
+ new
@@ -7,10 +7,11 @@
#ifdef GIT_SSH
#include <libssh2.h>
#endif
+#include "global.h"
#include "git2.h"
#include "buffer.h"
#include "netops.h"
#include "smart.h"
#include "cred.h"
@@ -891,14 +892,25 @@
giterr_set(GITERR_INVALID, "cannot create SSH transport. Library was built without SSH support");
return -1;
#endif
}
+#ifdef GIT_SSH
+static void shutdown_ssh(void)
+{
+ libssh2_exit();
+}
+#endif
+
int git_transport_ssh_global_init(void)
{
#ifdef GIT_SSH
+ if (libssh2_init(0) < 0) {
+ giterr_set(GITERR_SSH, "unable to initialize libssh2");
+ return -1;
+ }
- libssh2_init(0);
+ git__on_shutdown(shutdown_ssh);
return 0;
#else
/* Nothing to initialize */