soup patch, 29731
Not Zed <[email protected]> 28 Oct 2002 16:39:15 +1030
| Newsgroups | gmane.comp.gnome.ximian.soup |
|---|---|
| Message-ID | <[email protected]> |
Patch addresses 29731, I'm not sure all cases are completely handled, for example a successful immediate connect, should that return NULL or not? But otherwise it fixes the crash in 29371, tho maybe it could use some neatening (e.g. unused enum's). There is also a small patch to fix another problem with cancelled connections never being discounted, which means after 10 cancellations, connections are never re-initiated. Which basically stops image loading working at all. And finally a patch (request of Larry) to turn of the PTRACE debugging, as it just hinders doing any debugging with it turned on. Michael
29731.diff
(text/plain, 5.8 KB)
? patches.diff ? soup-transfer.c ? src/libsoup/b ? src/libsoup/soup.diff Index: ChangeLog =================================================================== RCS file: /cvs/gnome/soup/ChangeLog,v retrieving revision 1.229.2.40.2.51 diff -u -3 -r1.229.2.40.2.51 ChangeLog --- ChangeLog 16 Oct 2002 19:44:35 -0000 1.229.2.40.2.51 +++ ChangeLog 28 Oct 2002 06:01:24 -0000 @@ -1,3 +1,18 @@ +2002-10-28 Not Zed <[email protected]> + + * src/libsoup/soup-socket-unix.c: Disable the PTRACE_ATTACH code + always, because it reportedly causes problems. + + * src/libsoup/soup-context.c (soup_context_cancel_connect): If we + have a connection tag, decrement the connection_count setup in + try_create_connection. Stops soup 'failing' after a while. + + * src/libsoup/soup-socket.c (soup_socket_connect): Change logic to + free any data ourselves. + (soup_socket_connect_inetaddr_cb): Only free data if called via + mainloop. + (soup_socket_connect_tcp_cb): Same. See bug #29731. + 2002-10-16 Joe Shaw <[email protected]> * src/libsoup/soup-misc.c: Don't set SSL environment variables, Index: src/libsoup/soup-context.c =================================================================== RCS file: /cvs/gnome/soup/src/libsoup/soup-context.c,v retrieving revision 1.39.2.4.2.2 diff -u -3 -r1.39.2.4.2.2 soup-context.c --- src/libsoup/soup-context.c 1 Aug 2002 17:40:48 -0000 1.39.2.4.2.2 +++ src/libsoup/soup-context.c 28 Oct 2002 06:01:25 -0000 @@ -559,8 +559,10 @@ if (data->timeout_tag) g_source_remove (data->timeout_tag); - else if (data->connect_tag) + else if (data->connect_tag) { + connection_count--; soup_socket_connect_cancel (data->connect_tag); + } g_free (data); } Index: src/libsoup/soup-socket-unix.c =================================================================== RCS file: /cvs/gnome/soup/src/libsoup/soup-socket-unix.c,v retrieving revision 1.12.2.6.2.1 diff -u -3 -r1.12.2.6.2.1 soup-socket-unix.c --- src/libsoup/soup-socket-unix.c 7 Aug 2002 01:52:50 -0000 1.12.2.6.2.1 +++ src/libsoup/soup-socket-unix.c 28 Oct 2002 06:01:28 -0000 @@ -68,6 +68,11 @@ # endif #endif +/* this generally causes problems, so remove from build atm */ +#ifdef SOUP_PTRACE_ATTACH +#undef SOUP_PTRACE_ATTACH +#endif + #ifndef socklen_t #define socklen_t size_t #endif Index: src/libsoup/soup-socket.c =================================================================== RCS file: /cvs/gnome/soup/src/libsoup/soup-socket.c,v retrieving revision 1.24.2.9 diff -u -3 -r1.24.2.9 soup-socket.c --- src/libsoup/soup-socket.c 7 Mar 2002 17:14:33 -0000 1.24.2.9 +++ src/libsoup/soup-socket.c 28 Oct 2002 06:01:28 -0000 @@ -42,10 +42,20 @@ #define SOUP_SOCKADDR_IN(s) (*((struct sockaddr_in*) &s)) +enum { + SOCKET_CONNECT_SETUP, + SOCKET_CONNECT_ADDR, + SOCKET_CONNECT_CONN, + SOCKET_CONNECT_ERROR, + SOCKET_CONNECT_OK, +}; + typedef struct { SoupSocketConnectFn func; gpointer data; + int state; + gpointer inetaddr_id; gpointer tcp_id; } SoupSocketConnectState; @@ -314,17 +324,24 @@ SoupSocketConnectState* state = (SoupSocketConnectState*) data; SoupSocketConnectFn func = state->func; gpointer user_data = state->data; + int next; - g_free (state); - - if (status == SOUP_SOCKET_NEW_STATUS_OK) + if (status == SOUP_SOCKET_NEW_STATUS_OK) { + next = SOCKET_CONNECT_OK; (*func) (socket, SOUP_SOCKET_CONNECT_ERROR_NONE, user_data); - else + } else { + next = SOCKET_CONNECT_ERROR; (*func) (NULL, SOUP_SOCKET_CONNECT_ERROR_NETWORK, user_data); + } + + if (state->state == SOCKET_CONNECT_SETUP) + state->state = next; + else + g_free(state); } static void @@ -333,33 +350,39 @@ gpointer data) { SoupSocketConnectState* state = (SoupSocketConnectState*) data; + int next; if (status == SOUP_ADDRESS_STATUS_OK) { gpointer tcp_id; state->inetaddr_id = NULL; - + state->state = SOCKET_CONNECT_SETUP; tcp_id = soup_socket_new (inetaddr, soup_socket_connect_tcp_cb, state); + next = SOCKET_CONNECT_ADDR; /* * NOTE: soup_socket_new can fail immediately and call our * callback which will delete the state. */ - if (tcp_id) - state->tcp_id = tcp_id; + state->tcp_id = tcp_id; soup_address_unref (inetaddr); } else { SoupSocketConnectFn func = state->func; gpointer user_data = state->data; - g_free (state); - (*func) (NULL, SOUP_SOCKET_CONNECT_ERROR_ADDR_RESOLVE, user_data); + + next = SOCKET_CONNECT_ERROR; } + + if (state->state == SOCKET_CONNECT_SETUP) + state->state = next; + else + g_free(state); } /** @@ -389,6 +412,7 @@ SoupSocketConnectState* state; SoupAddress *cached_addr; gpointer addr_id, tcp_id; + int next; g_return_val_if_fail (hostname != NULL, NULL); g_return_val_if_fail (func != NULL, NULL); @@ -396,6 +420,7 @@ state = g_new0 (SoupSocketConnectState, 1); state->func = func; state->data = data; + state->state = SOCKET_CONNECT_SETUP; /* Check if a cached version of the address already exists */ cached_addr = soup_address_lookup_in_cache (hostname, port); @@ -409,11 +434,8 @@ * NOTE: soup_socket_new can fail immediately and call our * callback which will delete the state. */ - if (tcp_id) { - state->tcp_id = tcp_id; - return state; - } else - return NULL; + state->tcp_id = tcp_id; + next = SOCKET_CONNECT_CONN; } else { addr_id = soup_address_new (hostname, port, @@ -424,11 +446,18 @@ * NOTE: soup_address_new can fail immediately and call our * callback which will delete the state. */ - if (addr_id) { - state->inetaddr_id = addr_id; - return state; - } else - return NULL; + state->inetaddr_id = addr_id; + next = SOCKET_CONNECT_ADDR; + } + + if (state->state == SOCKET_CONNECT_ERROR) { + g_free(state); + + return NULL; + } else { + state->state = next; + + return state; } }