aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2010-05-17 11:19:31 +0200
committerAndreas Schneider <asn@cynapses.org>2010-08-25 23:12:26 +0200
commitedc6b2cef276d62034a6dd3f8ef5338e1a467045 (patch)
tree635258053877dc65479f776443a8e4aace4b3225
parent9590a643ab6d028770964cb27833f6eece094520 (diff)
downloadlibssh-edc6b2cef276d62034a6dd3f8ef5338e1a467045.tar.gz
libssh-edc6b2cef276d62034a6dd3f8ef5338e1a467045.tar.xz
libssh-edc6b2cef276d62034a6dd3f8ef5338e1a467045.zip
poll: Added a cleanup function to free the ws2_32 library.
-rw-r--r--include/libssh/poll.h1
-rw-r--r--include/libssh/socket.h1
-rw-r--r--libssh/init.c1
-rw-r--r--libssh/poll.c12
-rw-r--r--libssh/socket.c10
5 files changed, 24 insertions, 1 deletions
diff --git a/include/libssh/poll.h b/include/libssh/poll.h
index f54b614a..afa6be19 100644
--- a/include/libssh/poll.h
+++ b/include/libssh/poll.h
@@ -115,6 +115,7 @@ typedef unsigned long int nfds_t;
#endif /* HAVE_POLL */
void ssh_poll_init(void);
+void ssh_poll_cleanup(void);
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
typedef struct ssh_poll_ctx_struct *ssh_poll_ctx;
typedef struct ssh_poll_handle_struct *ssh_poll_handle;
diff --git a/include/libssh/socket.h b/include/libssh/socket.h
index 3e433e1f..3ce14f9d 100644
--- a/include/libssh/socket.h
+++ b/include/libssh/socket.h
@@ -30,6 +30,7 @@ struct socket *ssh_socket_new(ssh_session session);
void ssh_socket_free(struct socket *s);
void ssh_socket_set_fd(struct socket *s, socket_t fd);
socket_t ssh_socket_get_fd(struct socket *s);
+void ssh_socket_cleanup(void);
#ifndef _WIN32
int ssh_socket_unix(struct socket *s, const char *path);
#endif
diff --git a/libssh/init.c b/libssh/init.c
index bab9cdfb..bf84bc1d 100644
--- a/libssh/init.c
+++ b/libssh/init.c
@@ -65,6 +65,7 @@ int ssh_init(void) {
int ssh_finalize(void) {
ssh_regex_finalize();
ssh_crypto_finalize();
+ ssh_socket_cleanup();
#ifdef HAVE_LIBGCRYPT
gcry_control(GCRYCTL_TERM_SECMEM);
#elif defined HAVE_LIBCRYPTO
diff --git a/libssh/poll.c b/libssh/poll.c
index d74216b0..b6b4a430 100644
--- a/libssh/poll.c
+++ b/libssh/poll.c
@@ -63,6 +63,10 @@ void ssh_poll_init(void) {
return;
}
+void ssh_poll_cleanup(void) {
+ return;
+}
+
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
return poll((struct pollfd *) fds, nfds, timeout);
}
@@ -234,6 +238,14 @@ void ssh_poll_init(void) {
}
}
+void ssh_poll_cleanup(void) {
+ win_poll = bsd_poll;
+
+ FreeLibrary(hlib);
+
+ hlib = NULL;
+}
+
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
return win_poll(fds, nfds, timeout);
}
diff --git a/libssh/socket.c b/libssh/socket.c
index 402a5b78..516639c3 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -77,7 +77,15 @@ int ssh_socket_init(void) {
return 0;
}
-/*
+
+/**
+ * @brief Cleanup the socket system.
+ */
+void ssh_socket_cleanup(void) {
+ ssh_poll_cleanup();
+}
+
+/**
* \internal
* \brief creates a new Socket object
*/