Filippo Giunchedi has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/193097

Change subject: add debian patches to upstream
......................................................................

add debian patches to upstream

Bug: T90111
Change-Id: Ib2f6817ac714c7663adb2cca1b409dd38dc51cd3
---
A debian/patches/0001-add-missing-includes-from-ev.c.patch
A debian/patches/0002-dynamically-link-libev-if-available.patch
A debian/patches/0003-provide-libev-multiloop-support.patch
A debian/patches/series
4 files changed, 282 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/statsite 
refs/changes/97/193097/2

diff --git a/debian/patches/0001-add-missing-includes-from-ev.c.patch 
b/debian/patches/0001-add-missing-includes-from-ev.c.patch
new file mode 100644
index 0000000..232ec50
--- /dev/null
+++ b/debian/patches/0001-add-missing-includes-from-ev.c.patch
@@ -0,0 +1,25 @@
+From: Filippo Giunchedi <fgiunch...@wikimedia.org>
+Date: Wed, 25 Feb 2015 23:40:31 +0000
+Subject: add missing includes from ev.c
+
+if including only ev.h these headers are missing
+---
+ src/networking.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/networking.c b/src/networking.c
+index dabd2b8..20f720f 100644
+--- a/src/networking.c
++++ b/src/networking.c
+@@ -8,6 +8,11 @@
+ #include <syslog.h>
+ #include <unistd.h>
+ #include <netdb.h>
++#include <string.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <errno.h>
++#include <assert.h>
+ 
+ #include "networking.h"
+ #include "conn_handler.h"
diff --git a/debian/patches/0002-dynamically-link-libev-if-available.patch 
b/debian/patches/0002-dynamically-link-libev-if-available.patch
new file mode 100644
index 0000000..b0e0bee
--- /dev/null
+++ b/debian/patches/0002-dynamically-link-libev-if-available.patch
@@ -0,0 +1,57 @@
+From: Filippo Giunchedi <fgiunch...@wikimedia.org>
+Date: Wed, 25 Feb 2015 23:42:17 +0000
+Subject: dynamically link libev if available
+
+---
+ SConstruct       | 13 +++++++++++--
+ src/networking.c |  5 +++++
+ 2 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/SConstruct b/SConstruct
+index 629880c..4bfeaac 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -6,8 +6,15 @@ murmur = envmurmur.Library('murmur', 
Glob("deps/murmurhash/*.c"))
+ envinih = Environment(CPATH = ['deps/inih/'], CFLAGS="-O3")
+ inih = envinih.Library('inih', Glob("deps/inih/*.c"))
+ 
+-env_statsite_with_err = Environment(CCFLAGS = '-g -std=c99 -D_GNU_SOURCE 
-Wall -Werror -Wstrict-aliasing=0 -O3 -pthread -Ideps/inih/ -Ideps/libev/ 
-Isrc/')
+-env_statsite_without_err = Environment(CCFLAGS = '-g -std=c99 -D_GNU_SOURCE 
-O3 -pthread -Ideps/inih/ -Ideps/libev/ -Isrc/')
++ccflags = '-g -std=c99 -D_GNU_SOURCE -O3 -pthread -Ideps/inih/ -Isrc/'
++
++conf_libev = Environment().Configure()
++libev = conf_libev.CheckLibWithHeader('ev', 'ev.h', 'c', autoadd=0)
++if not libev:
++   ccflags += ' -Ideps/libev/ -D_DEPS_LIBEV'
++
++env_statsite_with_err = Environment(CCFLAGS = ccflags + ' -Wall 
-Wstrict-aliasing=0 -Werror')
++env_statsite_without_err = Environment(CCFLAGS = ccflags)
+ 
+ objs = env_statsite_with_err.Object('src/hashmap', 'src/hashmap.c')           
+ \
+         env_statsite_with_err.Object('src/heap', 'src/heap.c')                
+ \
+@@ -25,6 +32,8 @@ objs = env_statsite_with_err.Object('src/hashmap', 
'src/hashmap.c')           +
+         env_statsite_without_err.Object('src/conn_handler', 
'src/conn_handler.c')
+ 
+ statsite_libs = ["m", "pthread", murmur, inih]
++if libev:
++   statsite_libs.append("ev")
+ if platform.system() == 'Linux':
+    statsite_libs.append("rt")
+ 
+diff --git a/src/networking.c b/src/networking.c
+index 20f720f..498d31d 100644
+--- a/src/networking.c
++++ b/src/networking.c
+@@ -32,7 +32,12 @@
+ #ifdef __MACH__
+ #define EV_USE_KQUEUE 1
+ #endif
++
++#ifdef _DEPS_LIBEV
+ #include "ev.c"
++#else
++#include <ev.h>
++#endif
+ 
+ /**
+  * Default listen backlog size for
diff --git a/debian/patches/0003-provide-libev-multiloop-support.patch 
b/debian/patches/0003-provide-libev-multiloop-support.patch
new file mode 100644
index 0000000..c3505d0
--- /dev/null
+++ b/debian/patches/0003-provide-libev-multiloop-support.patch
@@ -0,0 +1,197 @@
+From: Filippo Giunchedi <fgiunch...@wikimedia.org>
+Date: Thu, 26 Feb 2015 12:59:28 +0000
+Subject: provide libev multiloop support
+
+---
+ src/networking.c | 49 +++++++++++++++++++++++++------------------------
+ 1 file changed, 25 insertions(+), 24 deletions(-)
+
+diff --git a/src/networking.c b/src/networking.c
+index 498d31d..8625375 100644
+--- a/src/networking.c
++++ b/src/networking.c
+@@ -21,9 +21,7 @@
+ #define MAX_PORT_LEN 6
+ 
+ #define EV_STANDALONE 1
+-#define EV_API_STATIC 1
+ #define EV_COMPAT3 0
+-#define EV_MULTIPLICITY 0
+ #define EV_USE_MONOTONIC 1
+ #ifdef __linux__
+ #define EV_USE_CLOCK_SYSCALL 0
+@@ -34,8 +32,11 @@
+ #endif
+ 
+ #ifdef _DEPS_LIBEV
++#define EV_MULTIPLICITY 0
++#define EV_API_STATIC 1
+ #include "ev.c"
+ #else
++#define EV_MULTIPLICITY 1
+ #include <ev.h>
+ #endif
+ 
+@@ -108,10 +109,10 @@ struct statsite_networking {
+ 
+ 
+ // Static typedefs
+-static void handle_flush_event(ev_timer *watcher, int revents);
+-static void handle_new_client(ev_io *watcher, int ready_events);
+-static void handle_udp_message(ev_io *watch, int ready_events);
+-static void invoke_event_handler(ev_io *watch, int ready_events);
++static void handle_flush_event(EV_P_ ev_timer *watcher, int revents);
++static void handle_new_client(EV_P_ ev_io *watcher, int ready_events);
++static void handle_udp_message(EV_P_ ev_io *watch, int ready_events);
++static void invoke_event_handler(EV_P_ ev_io *watch, int ready_events);
+ 
+ // Utility methods
+ static int set_client_sockopts(int client_fd);
+@@ -192,7 +193,7 @@ static int setup_tcp_listener(statsite_networking 
*netconf) {
+     // Create the libev objects
+     ev_io_init(&netconf->tcp_client, handle_new_client,
+                 tcp_listener_fd, EV_READ);
+-    ev_io_start(&netconf->tcp_client);
++    ev_io_start(EV_DEFAULT_UC_ &netconf->tcp_client);
+     return 0;
+ }
+ 
+@@ -266,7 +267,7 @@ static int setup_udp_listener(statsite_networking 
*netconf) {
+     // Create the libev objects
+     ev_io_init(&netconf->udp_client, handle_udp_message,
+                 udp_listener_fd, EV_READ);
+-    ev_io_start(&netconf->udp_client);
++    ev_io_start(EV_DEFAULT_UC_ &netconf->udp_client);
+     return 0;
+ }
+ 
+@@ -290,7 +291,7 @@ static int setup_stdin_listener(statsite_networking 
*netconf) {
+ 
+     // Initialize the libev stuff
+     ev_io_init(&conn->client, invoke_event_handler, STDIN_FILENO, EV_READ);
+-    ev_io_start(&conn->client);
++    ev_io_start(EV_DEFAULT_UC_ &conn->client);
+     return 0;
+ }
+ 
+@@ -339,7 +340,7 @@ int init_networking(statsite_config *config, 
statsite_networking **netconf_out)
+     res = setup_udp_listener(netconf);
+     if (res != 0) {
+         if (ev_is_active(&netconf->tcp_client)) {
+-            ev_io_stop(&netconf->tcp_client);
++            ev_io_stop(EV_DEFAULT_UC_ &netconf->tcp_client);
+             close(netconf->tcp_client.fd);
+         }
+         free(netconf);
+@@ -348,7 +349,7 @@ int init_networking(statsite_config *config, 
statsite_networking **netconf_out)
+ 
+     // Setup the timer
+     ev_timer_init(&netconf->flush_timer, handle_flush_event, 
config->flush_interval, config->flush_interval);
+-    ev_timer_start(&netconf->flush_timer);
++    ev_timer_start(EV_DEFAULT_UC_ &netconf->flush_timer);
+ 
+     // Prepare the conn handlers
+     init_conn_handler(config);
+@@ -363,7 +364,7 @@ int init_networking(statsite_config *config, 
statsite_networking **netconf_out)
+  * Invoked when our flush timer is reached.
+  * We need to instruct the connection handler about this.
+  */
+-static void handle_flush_event(ev_timer *watcher, int revents) {
++static void handle_flush_event(EV_P_ ev_timer *watcher, int revents) {
+     // Inform the connection handler of the timeout
+     flush_interval_trigger();
+ }
+@@ -374,7 +375,7 @@ static void handle_flush_event(ev_timer *watcher, int 
revents) {
+  * to accept a new client. Accepts the client, initializes
+  * the connection buffers, and stars to listening for data
+  */
+-static void handle_new_client(ev_io *watcher, int ready_events) {
++static void handle_new_client(EV_P_ ev_io *watcher, int ready_events) {
+     // Accept the client connection
+     int listen_fd = watcher->fd;
+     struct sockaddr_in client_addr;
+@@ -403,7 +404,7 @@ static void handle_new_client(ev_io *watcher, int 
ready_events) {
+ 
+     // Initialize the libev stuff
+     ev_io_init(&conn->client, invoke_event_handler, client_fd, EV_READ);
+-    ev_io_start(&conn->client);
++    ev_io_start(EV_DEFAULT_UC_ &conn->client);
+ }
+ 
+ 
+@@ -458,7 +459,7 @@ static int read_client_data(conn_info *conn) {
+  * invoke the connection handlers who have the business logic
+  * of what to do.
+  */
+-static void handle_udp_message(ev_io *watch, int ready_events) {
++static void handle_udp_message(EV_P_ ev_io *watch, int ready_events) {
+     while (1) {
+         // Get the associated connection struct
+         conn_info *conn = watch->data;
+@@ -503,7 +504,7 @@ static void handle_udp_message(ev_io *watch, int 
ready_events) {
+             circbuf_write(&conn->input, "\n", 1);
+ 
+         // Get the user data
+-        worker_ev_userdata *data = ev_userdata();
++        worker_ev_userdata *data = ev_userdata(EV_DEFAULT_UC);
+ 
+         // Invoke the connection handler
+         statsite_conn_handler handle = {data->netconf->config, watch->data};
+@@ -518,9 +519,9 @@ static void handle_udp_message(ev_io *watch, int 
ready_events) {
+  * stack should be handled here, but otherwise we should defer
+  * to the connection handlers.
+  */
+-static void invoke_event_handler(ev_io *watcher, int ready_events) {
++static void invoke_event_handler(EV_P_ ev_io *watcher, int ready_events) {
+     // Get the user data
+-    worker_ev_userdata *data = ev_userdata();
++    worker_ev_userdata *data = ev_userdata(EV_DEFAULT_UC);
+ 
+     // Read in the data, and close on issues
+     conn_info *conn = watcher->data;
+@@ -551,11 +552,11 @@ void enter_networking_loop(statsite_networking *netconf, 
volatile int *signum) {
+     data.netconf = netconf;
+ 
+     // Set the user data to be for this thread
+-    ev_set_userdata(&data);
++    ev_set_userdata(EV_DEFAULT_UC_ &data);
+ 
+     // Run forever until we are told to halt
+     while (likely(*signum == 0)) {
+-        ev_run(EVRUN_ONCE);
++        ev_run(EV_DEFAULT_UC_ EVRUN_ONCE);
+     }
+     return;
+ }
+@@ -568,11 +569,11 @@ void enter_networking_loop(statsite_networking *netconf, 
volatile int *signum) {
+ int shutdown_networking(statsite_networking *netconf) {
+     // Stop listening for new connections
+     if (ev_is_active(&netconf->tcp_client)) {
+-        ev_io_stop(&netconf->tcp_client);
++        ev_io_stop(EV_DEFAULT_UC_ &netconf->tcp_client);
+         close(netconf->tcp_client.fd);
+     }
+     if (ev_is_active(&netconf->udp_client)) {
+-        ev_io_stop(&netconf->udp_client);
++        ev_io_stop(EV_DEFAULT_UC_ &netconf->udp_client);
+         close(netconf->udp_client.fd);
+     }
+     if (netconf->stdin_client != NULL) {
+@@ -581,7 +582,7 @@ int shutdown_networking(statsite_networking *netconf) {
+     }
+ 
+     // Stop the other timers
+-    ev_timer_stop(&netconf->flush_timer);
++    ev_timer_stop(EV_DEFAULT_UC_ &netconf->flush_timer);
+ 
+     // TODO: Close all the client connections
+     // ??? For now, we just leak the memory
+@@ -610,7 +611,7 @@ int shutdown_networking(statsite_networking *netconf) {
+  */
+ void close_client_connection(conn_info *conn) {
+     // Stop the libev clients
+-    ev_io_stop(&conn->client);
++    ev_io_stop(EV_DEFAULT_UC_ &conn->client);
+ 
+     // Clear everything out
+     circbuf_free(&conn->input);
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..7af64ed
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,3 @@
+0001-add-missing-includes-from-ev.c.patch
+0002-dynamically-link-libev-if-available.patch
+0003-provide-libev-multiloop-support.patch

-- 
To view, visit https://gerrit.wikimedia.org/r/193097
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2f6817ac714c7663adb2cca1b409dd38dc51cd3
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/statsite
Gerrit-Branch: master
Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to