[evolution-patches] soup patches - 59240 (dns using 100% cpu), and iso C fixes
- From: Dan Winship <danw novell com>
- To: evolution-patches ximian com
- Cc: rc-hackers ximian com
- Subject: [evolution-patches] soup patches - 59240 (dns using 100% cpu), and iso C fixes
- Date: Tue, 01 Jun 2004 13:13:53 -0400
Part of this fixes the webcal-using-100%-cpu bug that seems to be
hitting everyone this week even though the code has always been buggy.
The rest of it fixes some non-ISO-C problems pointed out to me in
private email.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libsoup/ChangeLog,v
retrieving revision 1.429
diff -u -r1.429 ChangeLog
--- ChangeLog 19 May 2004 16:57:06 -0000 1.429
+++ ChangeLog 1 Jun 2004 17:08:51 -0000
@@ -1,3 +1,20 @@
+2004-06-01 Dan Winship <danw novell com>
+
+ * libsoup/soup-address.c: Redo the various IPv4/IPv6-abstracting
+ macros to not use ?: expressions as lvalues, since that's
+ apparently a GNU extension.
+ (soup_address_resolve_async): Use a timeout rather than an idle
+ handler to poll the dns result. (soup-dns really should be
+ rewritten to not require polling, but this is easier for now.)
+ #59240
+
+ * libsoup/soup-server.c (call_handler): Don't use GNU-only
+ non-constant structure initialization
+
+ * tests/dns.c: Simple test of the dns code
+
+ * tests/Makefile.am (noinst_PROGRAMS): build it
+
2004-05-19 JP Rosevear <jpr novell com>
* configure.in (SOUP_API_VERSION): bump version, libtool numbers
Index: libsoup/soup-address.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-address.c,v
retrieving revision 1.19
diff -u -r1.19 soup-address.c
--- libsoup/soup-address.c 5 Jan 2004 16:25:54 -0000 1.19
+++ libsoup/soup-address.c 1 Jun 2004 17:08:51 -0000
@@ -43,46 +43,66 @@
guint port;
SoupDNSEntry *lookup;
- guint idle_id;
+ guint timeout_id;
};
-#define SOUP_ADDRESS_PORT_IS_VALID(port) (port >= 0 && port <= 65535)
-#define SOUP_ADDRESS_FAMILY(addr) (addr->priv->sockaddr->sa_family)
+/* sockaddr generic macros */
#define SOUP_SIN(addr) ((struct sockaddr_in *)addr->priv->sockaddr)
-
#ifdef HAVE_IPV6
+#define SOUP_SIN6(addr) ((struct sockaddr_in6 *)addr->priv->sockaddr)
+#endif
-# define SOUP_SIN6(addr) ((struct sockaddr_in6 *)addr->priv->sockaddr)
-
-# define SOUP_ADDRESS_FAMILY_IS_VALID(family) \
+/* sockaddr family macros */
+#define SOUP_ADDRESS_GET_FAMILY(addr) (addr->priv->sockaddr->sa_family)
+#define SOUP_ADDRESS_SET_FAMILY(addr, family) \
+ (addr->priv->sockaddr->sa_family = family)
+#ifdef HAVE_IPV6
+#define SOUP_ADDRESS_FAMILY_IS_VALID(family) \
(family == AF_INET || family == AF_INET6)
-# define SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE(family) \
+#define SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE(family) \
(family == AF_INET ? sizeof (struct sockaddr_in) : \
sizeof (struct sockaddr_in6))
-# define SOUP_ADDRESS_FAMILY_DATA_SIZE(family) \
+#define SOUP_ADDRESS_FAMILY_DATA_SIZE(family) \
(family == AF_INET ? sizeof (struct in_addr) : \
sizeof (struct in6_addr))
+#else
+#define SOUP_ADDRESS_FAMILY_IS_VALID(family) (family == AF_INET)
+#define SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE(family) sizeof (struct sockaddr_in)
+#define SOUP_ADDRESS_FAMILY_DATA_SIZE(family) sizeof (struct in_addr)
+#endif
-# define SOUP_ADDRESS_DATA(addr) \
- (addr->priv->sockaddr->sa_family == AF_INET ? \
- (gpointer)&SOUP_SIN(addr)->sin_addr : \
- (gpointer)&SOUP_SIN6(addr)->sin6_addr)
-# define SOUP_ADDRESS_PORT(addr) \
+/* sockaddr port macros */
+#define SOUP_ADDRESS_PORT_IS_VALID(port) (port >= 0 && port <= 65535)
+#ifdef HAVE_IPV6
+#define SOUP_ADDRESS_GET_PORT(addr) \
(addr->priv->sockaddr->sa_family == AF_INET ? \
SOUP_SIN(addr)->sin_port : \
SOUP_SIN6(addr)->sin6_port)
-
+#define SOUP_ADDRESS_SET_PORT(addr, port) \
+ G_STMT_START { \
+ if (addr->priv->sockaddr->sa_family == AF_INET) \
+ SOUP_SIN(addr)->sin_port = port; \
+ else \
+ SOUP_SIN6(addr)->sin6_port = port; \
+ } G_STMT_END
#else
+#define SOUP_ADDRESS_GET_PORT(addr) (SOUP_SIN(addr)->sin_port)
+#define SOUP_ADDRESS_SET_PORT(addr, port) (SOUP_SIN(addr)->sin_port = port)
+#endif
-# define SOUP_ADDRESS_FAMILY_IS_VALID(family) (family == AF_INET6)
-# define SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE(family) sizeof (struct sockaddr_in)
-# define SOUP_ADDRESS_FAMILY_DATA_SIZE(family) sizeof (struct in_addr)
-
-# define SOUP_ADDRESS_DATA(addr) ((gpointer)&SOUP_SIN(addr)->sin_addr)
-# define SOUP_ADDRESS_PORT(addr) (SOUP_SIN(addr)->sin_port)
-
+/* sockaddr data macros */
+#ifdef HAVE_IPV6
+#define SOUP_ADDRESS_GET_DATA(addr) \
+ (addr->priv->sockaddr->sa_family == AF_INET ? \
+ (gpointer)&SOUP_SIN(addr)->sin_addr : \
+ (gpointer)&SOUP_SIN6(addr)->sin6_addr)
+#else
+#define SOUP_ADDRESS_GET_DATA(addr) ((gpointer)&SOUP_SIN(addr)->sin_addr)
#endif
+#define SOUP_ADDRESS_SET_DATA(addr, data, length) \
+ memcpy (SOUP_ADDRESS_GET_DATA (addr), data, length)
+
enum {
DNS_RESULT,
@@ -116,8 +136,8 @@
if (addr->priv->lookup)
soup_dns_entry_cancel_lookup (addr->priv->lookup);
- if (addr->priv->idle_id)
- g_source_remove (addr->priv->idle_id);
+ if (addr->priv->timeout_id)
+ g_source_remove (addr->priv->timeout_id);
g_free (addr->priv);
@@ -194,7 +214,7 @@
addr = g_object_new (SOUP_TYPE_ADDRESS, NULL);
addr->priv->sockaddr = g_memdup (sa, len);
- addr->priv->port = ntohs (SOUP_ADDRESS_PORT (addr));
+ addr->priv->port = ntohs (SOUP_ADDRESS_GET_PORT (addr));
return addr;
}
@@ -220,8 +240,8 @@
addr->priv->sockaddr =
g_malloc0 (SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (family));
- SOUP_ADDRESS_FAMILY (addr) = family;
- SOUP_ADDRESS_PORT (addr) = htons (port);
+ SOUP_ADDRESS_SET_FAMILY (addr, family);
+ SOUP_ADDRESS_SET_PORT (addr, htons (port));
return addr;
}
@@ -257,7 +277,7 @@
g_return_val_if_fail (SOUP_IS_ADDRESS (addr), NULL);
if (addr->priv->sockaddr && len)
- *len = SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (SOUP_ADDRESS_FAMILY (addr));
+ *len = SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (SOUP_ADDRESS_GET_FAMILY (addr));
return addr->priv->sockaddr;
}
@@ -281,8 +301,8 @@
if (!addr->priv->physical) {
addr->priv->physical =
- soup_dns_ntop (SOUP_ADDRESS_DATA (addr),
- SOUP_ADDRESS_FAMILY (addr));
+ soup_dns_ntop (SOUP_ADDRESS_GET_DATA (addr),
+ SOUP_ADDRESS_GET_FAMILY (addr));
}
return addr->priv->physical;
@@ -319,9 +339,9 @@
SOUP_ADDRESS_FAMILY_IS_VALID (h->h_addrtype) &&
SOUP_ADDRESS_FAMILY_DATA_SIZE (h->h_addrtype) == h->h_length) {
addr->priv->sockaddr = g_malloc0 (SOUP_ADDRESS_FAMILY_SOCKADDR_SIZE (h->h_addrtype));
- SOUP_ADDRESS_FAMILY (addr) = h->h_addrtype;
- SOUP_ADDRESS_PORT (addr) = htons (addr->priv->port);
- memcpy (SOUP_ADDRESS_DATA (addr), h->h_addr, h->h_length);
+ SOUP_ADDRESS_SET_FAMILY (addr, h->h_addrtype);
+ SOUP_ADDRESS_SET_PORT (addr, htons (addr->priv->port));
+ SOUP_ADDRESS_SET_DATA (addr, h->h_addr, h->h_length);
}
soup_dns_free_hostent (h);
@@ -333,13 +353,13 @@
}
static gboolean
-idle_check_lookup (gpointer user_data)
+timeout_check_lookup (gpointer user_data)
{
SoupAddress *addr = user_data;
guint status;
if (addr->priv->name && addr->priv->sockaddr) {
- addr->priv->idle_id = 0;
+ addr->priv->timeout_id = 0;
g_signal_emit (addr, signals[DNS_RESULT], 0, SOUP_STATUS_OK);
return FALSE;
}
@@ -349,7 +369,7 @@
status = update_address_from_entry (addr, addr->priv->lookup);
addr->priv->lookup = NULL;
- addr->priv->idle_id = 0;
+ addr->priv->timeout_id = 0;
g_signal_emit (addr, signals[DNS_RESULT], 0, status);
return FALSE;
@@ -379,7 +399,7 @@
G_CALLBACK (callback), user_data);
}
- if (addr->priv->idle_id)
+ if (addr->priv->timeout_id)
return;
if (!addr->priv->sockaddr) {
@@ -387,11 +407,11 @@
soup_dns_entry_from_name (addr->priv->name);
} else if (!addr->priv->name) {
addr->priv->lookup =
- soup_dns_entry_from_addr (SOUP_ADDRESS_DATA (addr),
- SOUP_ADDRESS_FAMILY (addr));
+ soup_dns_entry_from_addr (SOUP_ADDRESS_GET_DATA (addr),
+ SOUP_ADDRESS_GET_FAMILY (addr));
}
- addr->priv->idle_id = g_idle_add (idle_check_lookup, addr);
+ addr->priv->timeout_id = g_timeout_add (100, timeout_check_lookup, addr);
}
/**
@@ -413,8 +433,8 @@
if (addr->priv->name)
entry = soup_dns_entry_from_name (addr->priv->name);
else {
- entry = soup_dns_entry_from_addr (SOUP_ADDRESS_DATA (addr),
- SOUP_ADDRESS_FAMILY (addr));
+ entry = soup_dns_entry_from_addr (SOUP_ADDRESS_GET_DATA (addr),
+ SOUP_ADDRESS_GET_FAMILY (addr));
}
return update_address_from_entry (addr, entry);
Index: libsoup/soup-server.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-server.c,v
retrieving revision 1.55
diff -u -r1.55 soup-server.c
--- libsoup/soup-server.c 18 Nov 2003 16:00:21 -0000 1.55
+++ libsoup/soup-server.c 1 Jun 2004 17:08:51 -0000
@@ -385,19 +385,18 @@
if (hand->callback) {
const SoupUri *uri = soup_message_get_uri (req);
+ SoupServerContext ctx;
- SoupServerContext serverctx = {
- req,
- uri->path,
- soup_method_get_id (req->method),
- auth,
- server,
- hand,
- sock
- };
+ ctx.msg = req;
+ ctx.path = uri->path;
+ ctx.method_id = soup_method_get_id (req->method);
+ ctx.auth = auth;
+ ctx.server = server;
+ ctx.handler = hand;
+ ctx.sock = sock;
/* Call method handler */
- (*hand->callback) (&serverctx, req, hand->user_data);
+ (*hand->callback) (&ctx, req, hand->user_data);
}
if (auth)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]