From: Vladimir Vukicevic Date: Mon, 17 Sep 2001 17:24:57 +0000 (+0000) Subject: Added soup_address_copy(). Changed soup_address_new to check whether the X-Git-Tag: SOUP_0_6_0~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4d3e95da0d25d738c53d1b7b7be42a47376251c;p=platform%2Fupstream%2Flibsoup.git Added soup_address_copy(). Changed soup_address_new to check whether the * src/libsoup/soup-socket.c, src/libsoup/soup-socket.h: Added soup_address_copy(). Changed soup_address_new to check whether the ports are the same before using a cached address. --- diff --git a/ChangeLog b/ChangeLog index 39a50a6..3d15584 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-09-17 Vladimir Vukicevic + + * src/libsoup/soup-socket.c, src/libsoup/soup-socket.h: + Added soup_address_copy(). Changed soup_address_new to check + whether the ports are the same before using a cached + address. + 2001-09-14 Alex Graveley * src/libsoup/soup-serializer.c diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c index 75193dc..c7b964c 100644 --- a/libsoup/soup-socket.c +++ b/libsoup/soup-socket.c @@ -691,15 +691,24 @@ soup_address_new (const gchar* name, /* * Existing valid request, use it. */ - soup_address_ref (ia); + if (soup_address_get_port (ia) == port) { + soup_address_ref (ia); + } else { + SoupAddress *new_ia = soup_address_copy (ia); + /* We can reuse the address, but we have to change port */ + soup_address_set_port (new_ia, port); + ia = new_ia; + } (*func) (ia, SOUP_ADDRESS_STATUS_OK, data); - return NULL; - } else if (ia) { + } else if (ia && soup_address_get_port (ia) == port) { /* * Lookup currently in progress. * Add func to list of callbacks in state. + * Note that if it's not the same port, we have to do + * the lookup again, since there's no way to communicate + * the port change. */ SoupAddressCbData *cb_data; @@ -1074,6 +1083,27 @@ soup_address_unref (SoupAddress* ia) } } +/** + * soup_address_copy + * @ia: SoupAddress to copy + * + * Creates a copy of the given SoupAddress + **/ +SoupAddress * +soup_address_copy (SoupAddress* ia) +{ + SoupAddress* new_ia; + g_return_val_if_fail (ia != NULL, NULL); + + new_ia = g_new0(SoupAddress, 1); + new_ia->ref_count = 1; + + new_ia->name = g_strdup (ia->name); + memcpy (&new_ia->sa, &ia->sa, sizeof(struct sockaddr)); + + return new_ia; +} + #ifndef SOUP_WIN32 /*********** Unix code ***********/ static gboolean @@ -1428,8 +1458,10 @@ soup_address_get_name_sync (SoupAddress *addr) { const char *ret = (const char *) 0xdeadbeef; - soup_address_get_name (addr, - soup_address_get_name_sync_cb, + soup_address_get_name (addr, + + soup_address_get_name_sync_cb, + (gpointer) &ret); while (1) { diff --git a/libsoup/soup-socket.h b/libsoup/soup-socket.h index 47be597..c1a6e5e 100644 --- a/libsoup/soup-socket.h +++ b/libsoup/soup-socket.h @@ -43,6 +43,8 @@ void soup_address_ref (SoupAddress* ia); void soup_address_unref (SoupAddress* ia); +SoupAddress * soup_address_copy (SoupAddress* ia); + typedef gpointer SoupAddressGetNameId;