Merge lp:~brianaker/gearmand/cyassl-1.2-part-2 into lp:gearmand

Proposed by Brian Aker
Status: Merged
Merged at revision: 738
Proposed branch: lp:~brianaker/gearmand/cyassl-1.2-part-2
Merge into: lp:gearmand
Diff against target: 264 lines (+118/-8)
8 files modified
configure.ac (+3/-0)
libgearman-server/include.am (+1/-0)
libgearman-server/io.cc (+16/-1)
libgearman-server/plugins/protocol/gear/protocol.cc (+74/-6)
libgearman-server/struct/gearmand.h (+7/-0)
libgearman-server/struct/io.h (+7/-0)
libgearman/connection.hpp (+8/-0)
libgearman/include.am (+2/-1)
To merge this branch: bzr merge lp:~brianaker/gearmand/cyassl-1.2-part-2
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+163451@code.launchpad.net

Description of the change

Don't expect make test to work.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-05-12 20:30:19 +0000
+++ configure.ac 2013-05-13 02:54:27 +0000
@@ -208,6 +208,9 @@
208AC_CHECK_FUNC([bind],[],[AC_CHECK_LIB([bind],[bind])])208AC_CHECK_FUNC([bind],[],[AC_CHECK_LIB([bind],[bind])])
209209
210210
211# Check for CyaSSL
212AX_CHECK_LIBRARY([CYASSL],[cyassl/ssl.h],[cyassl])
213
211# Check for the ability to call dlopen (used in libhostile)214# Check for the ability to call dlopen (used in libhostile)
212AX_DLOPEN215AX_DLOPEN
213216
214217
=== modified file 'libgearman-server/include.am'
--- libgearman-server/include.am 2013-05-06 11:51:41 +0000
+++ libgearman-server/include.am 2013-05-13 02:54:27 +0000
@@ -95,3 +95,4 @@
95libgearman_server_libgearman_server_la_LIBADD+= @LIBM@95libgearman_server_libgearman_server_la_LIBADD+= @LIBM@
96libgearman_server_libgearman_server_la_LIBADD+= @DL_LIB@96libgearman_server_libgearman_server_la_LIBADD+= @DL_LIB@
97libgearman_server_libgearman_server_la_LIBADD+= @RT_LIB@97libgearman_server_libgearman_server_la_LIBADD+= @RT_LIB@
98libgearman_server_libgearman_server_la_LIBADD+= @CYASSL_LIB@
9899
=== modified file 'libgearman-server/io.cc'
--- libgearman-server/io.cc 2013-05-12 01:03:50 +0000
+++ libgearman-server/io.cc 2013-05-13 02:54:27 +0000
@@ -66,6 +66,12 @@
66 }66 }
67 else67 else
68 {68 {
69#if defined(HAVE_CYASSL) && HAVE_CYASSL
70 if (connection->root and connection->root->_ssl)
71 {
72 CyaSSL_shutdown(connection->root->_ssl);
73 }
74#endif
69 (void)gearmand_sockfd_close(connection->fd);75 (void)gearmand_sockfd_close(connection->fd);
70 assert_msg(false, "We should never have an internal fd");76 assert_msg(false, "We should never have an internal fd");
71 }77 }
@@ -99,7 +105,11 @@
99105
100 while (1)106 while (1)
101 {107 {
108#if defined(HAVE_CYASSL) && HAVE_CYASSL
109 read_size= CyaSSL_recv(con->_ssl, data, data_size, MSG_DONTWAIT);
110#else
102 read_size= recv(connection->fd, data, data_size, MSG_DONTWAIT);111 read_size= recv(connection->fd, data, data_size, MSG_DONTWAIT);
112#endif
103113
104 if (read_size == 0)114 if (read_size == 0)
105 {115 {
@@ -228,7 +238,12 @@
228 case gearmand_io_st::GEARMAND_CON_UNIVERSAL_CONNECTED:238 case gearmand_io_st::GEARMAND_CON_UNIVERSAL_CONNECTED:
229 while (connection->send_buffer_size)239 while (connection->send_buffer_size)
230 {240 {
231 ssize_t write_size= send(connection->fd, connection->send_buffer_ptr, connection->send_buffer_size, MSG_NOSIGNAL|MSG_DONTWAIT);241 ssize_t write_size;
242#if defined(HAVE_CYASSL) && HAVE_CYASSL
243 write_size= CyaSSL_send(con->_ssl, connection->send_buffer_ptr, connection->send_buffer_size, MSG_NOSIGNAL|MSG_DONTWAIT);
244#else
245 write_size= send(connection->fd, connection->send_buffer_ptr, connection->send_buffer_size, MSG_NOSIGNAL|MSG_DONTWAIT);
246#endif
232247
233 if (write_size == 0) // detect infinite loop?248 if (write_size == 0) // detect infinite loop?
234 {249 {
235250
=== modified file 'libgearman-server/plugins/protocol/gear/protocol.cc'
--- libgearman-server/plugins/protocol/gear/protocol.cc 2013-05-07 11:07:18 +0000
+++ libgearman-server/plugins/protocol/gear/protocol.cc 2013-05-13 02:54:27 +0000
@@ -50,9 +50,16 @@
50#include <cstdio>50#include <cstdio>
51#include <cstdlib>51#include <cstdlib>
5252
53#if defined(HAVE_CYASSL) && HAVE_CYASSL
54# include <cyassl/ssl.h>
55#endif
56
53#include <libgearman-server/plugins/protocol/gear/protocol.h>57#include <libgearman-server/plugins/protocol/gear/protocol.h>
54#include "libgearman/command.h"58#include "libgearman/command.h"
5559
60#define CERT_PEM "/home/brian/cyassl/certs/server-cert.pem"
61#define CERT_KEY_PEM "/home/brian/cyassl/certs/server-key.pem"
62
56static gearmand_error_t gearmand_packet_unpack_header(gearmand_packet_st *packet)63static gearmand_error_t gearmand_packet_unpack_header(gearmand_packet_st *packet)
57{64{
58 uint32_t tmp;65 uint32_t tmp;
@@ -300,9 +307,40 @@
300307
301static Geartext gear_context;308static Geartext gear_context;
302309
310#if defined(HAVE_CYASSL) && HAVE_CYASSL
311static struct CYASSL_CTX *ctx_ssl= NULL;
312#endif
313
303static gearmand_error_t _gear_con_add(gearman_server_con_st *connection)314static gearmand_error_t _gear_con_add(gearman_server_con_st *connection)
304{315{
305 gearmand_info("Gear connection made");316#if defined(HAVE_CYASSL) && HAVE_CYASSL
317 assert(ctx_ssl);
318 if ((connection->_ssl = CyaSSL_new(ctx_ssl)) == NULL)
319 {
320 return gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "CyaSSL_new() failed");
321 }
322
323 CyaSSL_set_fd(connection->_ssl, connection->con.fd);
324
325 bool connecting= true;
326 while (connecting)
327 {
328 if (CyaSSL_accept(connection->_ssl) == SSL_SUCCESS)
329 {
330 connecting= false;
331 break;
332 }
333
334 if (CyaSSL_get_error(connection->_ssl, 0) != SSL_ERROR_WANT_READ)
335 {
336 int cyassl_error= CyaSSL_get_error(connection->_ssl, 0);
337 char cyassl_error_buffer[1024]= { 0 };
338 CyaSSL_ERR_error_string(cyassl_error, cyassl_error_buffer);
339 return gearmand_log_error(GEARMAN_DEFAULT_LOG_PARAM, "%s(%d)", cyassl_error_buffer, cyassl_error);
340 }
341 }
342 gearmand_log_info(GEARMAN_DEFAULT_LOG_PARAM, "GearSSL connection made: %d", connection->con.fd);
343#endif
306344
307 connection->set_protocol(&gear_context);345 connection->set_protocol(&gear_context);
308346
@@ -314,11 +352,41 @@
314352
315Gear::Gear() :353Gear::Gear() :
316 Plugin("Gear")354 Plugin("Gear")
317{355 {
318 command_line_options().add_options()356 command_line_options().add_options()
319 ("port,p", boost::program_options::value(&_port)->default_value(GEARMAN_DEFAULT_TCP_PORT_STRING),357 ("port,p", boost::program_options::value(&_port)->default_value(GEARMAN_DEFAULT_TCP_PORT_STRING),
320 "Port the server should listen on.");358 "Port the server should listen on.");
321}359
360#if defined(HAVE_CYASSL) && HAVE_CYASSL
361 CyaSSL_Init();
362
363 ctx_ssl= CyaSSL_CTX_new(CyaTLSv1_2_server_method());
364
365 if (access(CERT_PEM, R_OK) == -1)
366 {
367 assert("access()" == NULL);
368 }
369
370 if (CyaSSL_CTX_use_certificate_file(ctx_ssl, CERT_PEM, SSL_FILETYPE_PEM) != SSL_SUCCESS)
371 {
372 CyaSSL_CTX_free(ctx_ssl);
373 gearmand_fatal("CyaSSL_CTX_use_certificate_file() cannot obtain certificate");
374 }
375
376 if (access(CERT_KEY_PEM, R_OK) == -1)
377 {
378 gearmand_fatal("access(CERT_KEY_PEM, R_OK) == -1");
379 }
380
381 if (CyaSSL_CTX_use_PrivateKey_file(ctx_ssl, CERT_KEY_PEM, SSL_FILETYPE_PEM) != SSL_SUCCESS)
382 {
383 CyaSSL_CTX_free(ctx_ssl);
384 gearmand_fatal("CyaSSL_CTX_use_PrivateKey_file() cannot obtain certificate");
385 }
386
387 assert(ctx_ssl);
388#endif
389 }
322390
323Gear::~Gear()391Gear::~Gear()
324{392{
325393
=== modified file 'libgearman-server/struct/gearmand.h'
--- libgearman-server/struct/gearmand.h 2013-05-05 01:54:09 +0000
+++ libgearman-server/struct/gearmand.h 2013-05-13 02:54:27 +0000
@@ -38,6 +38,9 @@
38#pragma once38#pragma once
3939
40#include "libgearman-server/struct/server.h"40#include "libgearman-server/struct/server.h"
41#if defined(HAVE_CYASSL) && HAVE_CYASSL
42# include <cyassl/ssl.h>
43#endif
4144
42#include "libgearman-server/struct/port.h"45#include "libgearman-server/struct/port.h"
4346
@@ -174,6 +177,10 @@
174 }177 }
175 }178 }
176 179
180#if defined(HAVE_CYASSL) && HAVE_CYASSL
181 CYASSL_CTX *ctx_ssl;
182#endif
183
177 bool exceptions() const184 bool exceptions() const
178 {185 {
179 return _exceptions;186 return _exceptions;
180187
=== modified file 'libgearman-server/struct/io.h'
--- libgearman-server/struct/io.h 2013-05-05 01:54:09 +0000
+++ libgearman-server/struct/io.h 2013-05-13 02:54:27 +0000
@@ -39,6 +39,10 @@
3939
40#include "libgearman-server/plugins/base.h"40#include "libgearman-server/plugins/base.h"
4141
42#if defined(HAVE_CYASSL) && HAVE_CYASSL
43# include <cyassl/ssl.h>
44#endif
45
42struct gearmand_io_st46struct gearmand_io_st
43{47{
44 struct {48 struct {
@@ -162,4 +166,7 @@
162 protocol= NULL;166 protocol= NULL;
163 }167 }
164 }168 }
169#if defined(HAVE_CYASSL) && HAVE_CYASSL
170 CYASSL* _ssl;
171#endif
165};172};
166173
=== modified file 'libgearman/connection.hpp'
--- libgearman/connection.hpp 2013-05-04 12:05:03 +0000
+++ libgearman/connection.hpp 2013-05-13 02:54:27 +0000
@@ -42,6 +42,10 @@
42#include "libgearman/interface/packet.hpp"42#include "libgearman/interface/packet.hpp"
43#include "libgearman/interface/universal.hpp"43#include "libgearman/interface/universal.hpp"
4444
45#if defined(HAVE_CYASSL) && HAVE_CYASSL
46# include <cyassl/ssl.h>
47#endif
48
45struct gearman_connection_st49struct gearman_connection_st
46{50{
47 struct Options {51 struct Options {
@@ -63,6 +67,10 @@
63 short events;67 short events;
64 short revents;68 short revents;
65 int fd;69 int fd;
70#if defined(HAVE_CYASSL) && HAVE_CYASSL
71 CYASSL* ssl;
72 CYASSL_CTX* ctx_ssl;
73#endif
66 int cached_errno;74 int cached_errno;
67 uint32_t created_id;75 uint32_t created_id;
68 uint32_t created_id_next;76 uint32_t created_id_next;
6977
=== modified file 'libgearman/include.am'
--- libgearman/include.am 2013-05-07 11:07:18 +0000
+++ libgearman/include.am 2013-05-13 02:54:27 +0000
@@ -133,8 +133,9 @@
133133
134libgearman_libgearman_la_LDFLAGS+= -version-info $(GEARMAN_LIBRARY_VERSION)134libgearman_libgearman_la_LDFLAGS+= -version-info $(GEARMAN_LIBRARY_VERSION)
135135
136libgearman_libgearman_la_LIBADD+= @CYASSL_LIB@
137libgearman_libgearman_la_LIBADD+= @DL_LIB@
136libgearman_libgearman_la_LIBADD+= @LIBUUID_LIB@138libgearman_libgearman_la_LIBADD+= @LIBUUID_LIB@
137libgearman_libgearman_la_LIBADD+= @DL_LIB@
138libgearman_libgearman_la_LIBADD+= libhashkit/libhashkit.la139libgearman_libgearman_la_LIBADD+= libhashkit/libhashkit.la
139140
140if TARGET_LINUX141if TARGET_LINUX

Subscribers

People subscribed via source and target branches

to all changes: