mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 02:11:40 +00:00
transports: ssh: clean up after libssh2 on exit
After calling `libssh2_init`, we need to clean up after the library by executing `libssh2_exit` as soon as we exit. Register a shutdown handler to do so which simply calls `libssh2_exit`. This fixes several memory leaks.
This commit is contained in:
parent
8c027351cb
commit
2ce2a48f2d
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
git_mutex git__mwindow_mutex;
|
git_mutex git__mwindow_mutex;
|
||||||
|
|
||||||
#define MAX_SHUTDOWN_CB 8
|
#define MAX_SHUTDOWN_CB 9
|
||||||
|
|
||||||
static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB];
|
static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB];
|
||||||
static git_atomic git__n_shutdown_callbacks;
|
static git_atomic git__n_shutdown_callbacks;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <libssh2.h>
|
#include <libssh2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
#include "git2.h"
|
#include "git2.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "netops.h"
|
#include "netops.h"
|
||||||
@ -893,6 +894,13 @@ int git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *p
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GIT_SSH
|
||||||
|
static void shutdown_ssh(void)
|
||||||
|
{
|
||||||
|
libssh2_exit();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int git_transport_ssh_global_init(void)
|
int git_transport_ssh_global_init(void)
|
||||||
{
|
{
|
||||||
#ifdef GIT_SSH
|
#ifdef GIT_SSH
|
||||||
@ -901,6 +909,7 @@ int git_transport_ssh_global_init(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git__on_shutdown(shutdown_ssh);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user