summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Kasik <mkasik@redhat.com>2010-06-03 10:13:17 +0200
committerMarek Kasik <mkasik@redhat.com>2010-06-03 10:13:17 +0200
commitf8ac1231923fe77eb243fe2333e83b03c29c8868 (patch)
tree057b0305f7e178f8840cea8252875cc8644d698f
parent9fbfbda8cc4ff3ec25211bb62502426f09e409b3 (diff)
downloadgtk+-f8ac1231923fe77eb243fe2333e83b03c29c8868.tar.gz
Test connection to all given addresses when printing
Go to the next address given by CUPS if we fail to connect to previous address (#603637).
-rw-r--r--modules/printbackends/cups/gtkcupsutils.c18
-rw-r--r--modules/printbackends/cups/gtkcupsutils.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/modules/printbackends/cups/gtkcupsutils.c b/modules/printbackends/cups/gtkcupsutils.c
index cd97f10efd..1023da09e6 100644
--- a/modules/printbackends/cups/gtkcupsutils.c
+++ b/modules/printbackends/cups/gtkcupsutils.c
@@ -1502,6 +1502,7 @@ gtk_cups_connection_test_new (const char *server)
result->socket = -1;
result->current_addr = NULL;
+ result->last_wrong_addr = NULL;
result->at_init = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
result->at_init = gtk_cups_connection_test_get_state (result);
@@ -1540,7 +1541,14 @@ gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
{
if (test->socket == -1)
{
- iter = test->addrlist;
+ if (test->last_wrong_addr != NULL && test->last_wrong_addr->next != NULL)
+ iter = test->last_wrong_addr->next;
+ else
+ {
+ test->last_wrong_addr = NULL;
+ iter = test->addrlist;
+ }
+
while (iter)
{
test->socket = socket (iter->addr.addr.sa_family,
@@ -1584,7 +1592,12 @@ gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
if (error_code == EALREADY || error_code == EINPROGRESS)
result = GTK_CUPS_CONNECTION_IN_PROGRESS;
else
- result = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
+ {
+ close (test->socket);
+ test->socket = -1;
+ test->last_wrong_addr = test->current_addr;
+ result = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
+ }
}
}
@@ -1605,6 +1618,7 @@ gtk_cups_connection_test_free (GtkCupsConnectionTest *test)
#ifdef HAVE_CUPS_API_1_2
test->current_addr = NULL;
+ test->last_wrong_addr = NULL;
httpAddrFreeList (test->addrlist);
if (test->socket != -1)
{
diff --git a/modules/printbackends/cups/gtkcupsutils.h b/modules/printbackends/cups/gtkcupsutils.h
index ba43f875f7..2438b86696 100644
--- a/modules/printbackends/cups/gtkcupsutils.h
+++ b/modules/printbackends/cups/gtkcupsutils.h
@@ -111,6 +111,7 @@ struct _GtkCupsConnectionTest
GtkCupsConnectionState at_init;
http_addrlist_t *addrlist;
http_addrlist_t *current_addr;
+ http_addrlist_t *last_wrong_addr;
gint socket;
#endif
};