This patch series adds another HTTPS plugin. It uses PolarSSL and has
been tested with v1.1.4 and v1.2.4. The first 3 patches are fixes in
monkey core required for the plugin to work. The plugin is not well
tested, but I've used Google Chrome, Mozilla Firefox, Safari, curl and
ab on it without problem.

The plugin should work with all plugins as long as they use
mk_api->socket calls. It does not change any epoll events or implement
any event callbacks.

By default it is assumed that the systems knows where polarssl is
located, but here are the needed variables to use with any directory.

$ CFLAGS="-I/path/to/polarssl/include" \
> LDFLAGS="-Wl,-rpath=/path/to/polarssl/library -L/path/to/polarssl/library" \
> ./configure --enable-plugins=polarssl

To enable the plugin, load as usually and set 'TransportLayer' in
monkey.conf to 'polarssl'.

To build the polarssl library from source you need to enable the shared
library.

$ cmake -DUSE_SHARED_POLARSSL_LIBRARY=on .

-- 
Sonny Karlsson
>From a9319fea2ee69dbc62e0b4fe498e2b6811e2a177 Mon Sep 17 00:00:00 2001
From: Sonny Karlsson <[email protected]>
Date: Thu, 31 Jan 2013 20:34:34 +0100
Subject: [PATCH 1/4] socket: Use close from transport plugin.

sched: Replace close call with mk_socket_close.

server: Replace close call with mk_socket_close.

lib: Replace close with mk_socket_close.

Signed-off-by: Sonny Karlsson <[email protected]>
---
 src/mk_lib.c       | 2 +-
 src/mk_scheduler.c | 4 ++--
 src/mk_server.c    | 2 +-
 src/mk_socket.c    | 3 +--
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/mk_lib.c b/src/mk_lib.c
index 1f0761f..74fff01 100644
--- a/src/mk_lib.c
+++ b/src/mk_lib.c
@@ -75,7 +75,7 @@ static void mklib_run(void *p)
         if (remote_fd == -1) continue;
 
         ret = mk_sched_add_client(remote_fd);
-        if (ret == -1) close(remote_fd);
+        if (ret == -1) mk_socket_close(remote_fd);
     }
 }
 
diff --git a/src/mk_scheduler.c b/src/mk_scheduler.c
index 4b14353..f41c6b5 100644
--- a/src/mk_scheduler.c
+++ b/src/mk_scheduler.c
@@ -336,7 +336,7 @@ int mk_sched_remove_client(struct sched_list_node *sched, 
int remote_fd)
      * on that.
      */
     mk_epoll_del(sched->epoll_fd, remote_fd);
-    close(remote_fd);
+    mk_socket_close(remote_fd);
 
     sc = mk_sched_get_connection(sched, remote_fd);
     if (sc) {
@@ -375,7 +375,7 @@ struct sched_connection *mk_sched_get_connection(struct 
sched_list_node *sched,
      */
     if (!sched) {
         MK_TRACE("[FD %i] No scheduler information", remote_fd);
-        close(remote_fd);
+        mk_socket_close(remote_fd);
         return NULL;
     }
 
diff --git a/src/mk_server.c b/src/mk_server.c
index 88b3ffd..857f08a 100644
--- a/src/mk_server.c
+++ b/src/mk_server.c
@@ -117,7 +117,7 @@ void mk_server_loop(int server_fd)
         /* Assign socket to worker thread */
         ret = mk_sched_add_client(remote_fd);
         if (ret == -1) {
-            close(remote_fd);
+            mk_socket_close(remote_fd);
         }
     }
 }
diff --git a/src/mk_socket.c b/src/mk_socket.c
index a737881..7b992d5 100644
--- a/src/mk_socket.c
+++ b/src/mk_socket.c
@@ -54,7 +54,6 @@ static void mk_socket_safe_event_write(int socket)
  */
 int mk_socket_set_cork_flag(int fd, int state)
 {
-
     MK_TRACE("Socket, set Cork Flag FD %i to %s", fd, (state ? "ON" : "OFF"));
 
     return setsockopt(fd, SOL_TCP, TCP_CORK, &state, sizeof(state));
@@ -88,7 +87,7 @@ int mk_socket_set_tcp_defer_accept(int sockfd)
 
 int mk_socket_close(int socket)
 {
-    return close(socket);
+    return plg_netiomap->close(socket);
 }
 
 int mk_socket_create()
-- 
1.8.0.2

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to