Skip to content

Commit

Permalink
Update to libsoup-2.48.1
Browse files Browse the repository at this point in the history
server code changes, client will be in another patch.

Change-Id: Ie861f3a17d7e5d3a4bd80b525211ab17a99c7d05
  • Loading branch information
p3ck committed Jan 8, 2015
1 parent 66e7980 commit a5c6fd9
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
/third-party/libarchive-3.1.2/
/third-party/libffi-3.1.tar.gz
/third-party/libffi-3.1/
/third-party/libsoup-2.42.3.tar.xz
/third-party/libsoup-2.42.3/
/third-party/libsoup-2.48.1.tar.xz
/third-party/libsoup-2.48.1/
/third-party/libxml2-2.9.1.tar.gz
/third-party/libxml2-2.9.1/
/third-party/xz-5.0.4.tar.gz
Expand Down
1 change: 1 addition & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <glib.h>
#include <libsoup/soup.h>
#include <time.h>
#include <stdint.h>
#include "message.h"

static GQueue *message_queue = NULL;
Expand Down
83 changes: 19 additions & 64 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include "recipe.h"
#include "task.h"
#include "errors.h"
Expand Down Expand Up @@ -424,8 +425,8 @@ server_control_callback (SoupServer *server, SoupMessage *client_msg,
// Monitor the socket, if the client disconnects
// it sets G_IO_IN, without this we won't notice
// the client going away until we try to write to it
SoupSocket *socket = soup_client_context_get_socket (context);
gint fd = soup_socket_get_fd (socket);
GSocket *socket = soup_client_context_get_gsocket (context);
gint fd = g_socket_get_fd (socket);
app_data->io_chan = g_io_channel_unix_new(fd);
app_data->io_handler_id = g_io_add_watch (app_data->io_chan,
G_IO_IN,
Expand Down Expand Up @@ -502,8 +503,7 @@ int main(int argc, char *argv[]) {
gint port = 8081;
app_data->config_file = NULL;
gchar *config_port = g_strdup("config.conf");
SoupServer *soup_server_ipv4 = NULL;
SoupServer *soup_server_ipv6 = NULL;
SoupServer *soup_server = NULL;
GError *error = NULL;

GOptionEntry entries [] = {
Expand Down Expand Up @@ -552,62 +552,20 @@ int main(int argc, char *argv[]) {
soup_session = soup_session_new();
soup_session_add_feature_by_type (soup_session, SOUP_TYPE_CONTENT_SNIFFER);

SoupAddress *addr_ipv6 = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6,
port);
soup_server_ipv6 = soup_server_new (SOUP_SERVER_INTERFACE, addr_ipv6, NULL);
g_object_unref (addr_ipv6);

// IPv6
guint ipv6_only = 1, len = sizeof (ipv6_only);

if (soup_server_ipv6) {
// get the socket file descriptor
gint socket_fd = soup_socket_get_fd (soup_server_get_listener (soup_server_ipv6));
// current libsoup defaults to GSocket defaults, this means we could
// get a dual ipv4/ipv6 socket. We need to check and only open an ipv4
// socket if not.
if (getsockopt (socket_fd, IPPROTO_IPV6, IPV6_V6ONLY,
(gpointer)&ipv6_only, (gpointer)&len) == -1) {
g_printerr ("Can't determine if IPV6_V6ONLY is set!\n");
}

// close soup_server socket on exec
fcntl (socket_fd, F_SETFD, FD_CLOEXEC);

// Add the handlers
soup_server_add_handler (soup_server_ipv6, "/run",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server_ipv6, "/continue",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server_ipv6, "/recipes",
server_recipe_callback, app_data, NULL);
// Run the server
soup_server_run_async (soup_server_ipv6);
}
// Define a soup server
soup_server = soup_server_new(SOUP_SERVER_SERVER_HEADER, "restraint ", NULL);

// IPv4
if (ipv6_only == 1) {
SoupAddress *addr_ipv4 = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4,
port);
soup_server_ipv4 = soup_server_new (SOUP_SERVER_INTERFACE, addr_ipv4, NULL);
g_object_unref (addr_ipv4);

// close soup_server socket on exec
gint socket_fd = soup_socket_get_fd (soup_server_get_listener (soup_server_ipv4));
fcntl (socket_fd, F_SETFD, FD_CLOEXEC);

// Add the handlers
soup_server_add_handler (soup_server_ipv4, "/run",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server_ipv4, "/continue",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server_ipv4, "/recipes",
server_recipe_callback, app_data, NULL);
// Run the server
soup_server_run_async (soup_server_ipv4);
}
// Add the handlers
soup_server_add_handler (soup_server, "/run",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server, "/continue",
server_control_callback, app_data, NULL);
soup_server_add_handler (soup_server, "/recipes",
server_recipe_callback, app_data, NULL);

if (!soup_server_ipv4 && !soup_server_ipv6) {
// Tell our soup server to listen on any interface
// This includes ipv4 and ipv6 if available.
if (! soup_server_listen_all (soup_server, port, 0, NULL)) {
g_printerr ("Unable to bind to server port %d\n", port);
exit (1);
}
Expand All @@ -625,12 +583,9 @@ int main(int argc, char *argv[]) {
soup_session_remove_feature_by_type (soup_session, SOUP_TYPE_CONTENT_SNIFFER);
g_object_unref(soup_session);

soup_server_disconnect(soup_server_ipv6);
g_object_unref(soup_server_ipv6);
if (ipv6_only == 1) {
soup_server_disconnect(soup_server_ipv4);
g_object_unref(soup_server_ipv4);
}
// no longer need to call soup_server_quit as disconnect does it all.
soup_server_disconnect(soup_server);
g_object_unref(soup_server);

restraint_free_app_data(app_data);
g_free(config_port);
Expand Down
5 changes: 2 additions & 3 deletions third-party/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LIBXML2 = libxml2-2.9.1
CURL = curl-7.29.0
LIBARCHIVE = libarchive-3.1.2
XZ = xz-5.0.4
LIBSOUP = libsoup-2.42.3
LIBSOUP = libsoup-2.48.1
SQLITE = sqlite-autoconf-3080002
INTLTOOL = intltool-0.35.5

Expand Down Expand Up @@ -143,7 +143,7 @@ $(INTLTOOL).tar.gz:

TAR_BALLS += $(LIBSOUP).tar.xz
$(LIBSOUP).tar.xz:
curl -O http://ftp.gnome.org/pub/GNOME/sources/libsoup/2.42/$@
curl -O http://ftp.gnome.org/pub/GNOME/sources/libsoup/2.48/$@

tarballs: $(TAR_BALLS)

Expand Down Expand Up @@ -189,7 +189,6 @@ $(LIBARCHIVE)/.patches-done:
$(LIBSOUP)/.patches-done:
patch -d$(LIBSOUP) -p1 <libsoup-no-pkgconfig-version-check.patch
patch -d$(LIBSOUP) -p1 <libsoup-perl580.patch
patch -d$(LIBSOUP) -p1 <libsoup_add_ppc64le.patch
touch $@

$(LIBXML2)/.patches-done:
Expand Down
12 changes: 6 additions & 6 deletions third-party/libsoup-no-pkgconfig-version-check.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
diff -ur libsoup-2.38.1/configure libsoup-2.38.1.patched/configure
--- libsoup-2.38.1/configure 2012-04-16 16:08:02.000000000 -0400
+++ libsoup-2.38.1.patched/configure 2013-02-19 09:52:32.000000000 -0500
@@ -11853,19 +11853,6 @@
--- libsoup-2.48.1.orig/configure 2014-12-07 10:00:41.000000000 -0500
+++ libsoup-2.48.1/configure 2015-01-06 08:37:28.623525413 -0500
@@ -11986,19 +11986,6 @@
fi

fi
Expand All @@ -21,16 +20,17 @@ diff -ur libsoup-2.38.1/configure libsoup-2.38.1.patched/configure

no_glib=""

@@ -13254,11 +13241,7 @@
@@ -13939,12 +13926,7 @@

if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
CFLAGS="$CFLAGS \
- -Wall -Wstrict-prototypes -Werror=missing-prototypes \
- -Werror=implicit-function-declaration \
- -Werror=pointer-arith -Werror=init-self -Werror=format=2 \
- -Wno-format-zero-length \
- -Werror=missing-include-dirs -Werror=aggregate-return \
- -Werror=declaration-after-statement"
+ -Wall -Wstrict-prototypes"
+ -Wall -Wstrict-prototypes -Wno-format-zero-length"
fi


14 changes: 0 additions & 14 deletions third-party/libsoup_add_ppc64le.patch

This file was deleted.

0 comments on commit a5c6fd9

Please sign in to comment.