abort failed queries

eocene <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
I wanted to inform the user when a query failed by showing a
message and greying out the stop icon instead of letting them
wait forever and wonder. Patch attached.

Examples:
starurchin.org (Connection refused at present, anyway. Fails immediately.)
auriga.wearlab.de (no server there, of course. Takes a minute or so.)
dillo.asdfgh (leaves the DNS error msgs alone and greys the stop icon.)

_______________________________________________
Dillo-dev mailing list
[email protected]
http://lists.dillo.org/cgi-bin/mailman/listinfo/dillo-dev
abort_failed_write.diff (text/x-diff, 2.6 KB)
diff -r c3a1c080990b src/IO/IO.c
--- a/src/IO/IO.c	Thu Jul 31 06:26:32 2014 +0000
+++ b/src/IO/IO.c	Thu Jul 31 16:32:36 2014 +0000
@@ -298,6 +298,8 @@
    } else {
       if (IO_callback(io) == 0)
          a_IOwatch_remove_fd(fd, DIO_WRITE);
+      if (io->Status)
+         a_IO_ccc(OpAbort, 1, FWD, io->Info, NULL, NULL);
    }
 }
 
@@ -385,6 +387,13 @@
       } else {  /* 1 FWD */
          /* Write-data status */
          switch (Op) {
+         case OpAbort:
+            io = Info->LocalKey;
+            IO_close_fd(io, IO_StopRdWr);
+            IO_free(io);
+            a_Chain_fcb(OpAbort, Info, NULL, NULL);
+            dFree(Info);
+            break;
          default:
             MSG_WARN("Unused CCC\n");
             break;
diff -r c3a1c080990b src/IO/http.c
--- a/src/IO/http.c	Thu Jul 31 06:26:32 2014 +0000
+++ b/src/IO/http.c	Thu Jul 31 16:32:36 2014 +0000
@@ -696,8 +696,19 @@
             break;
          }
       } else {  /* 1 FWD */
+         SocketData_t *sd;
          /* HTTP send-query status branch */
          switch (Op) {
+         case OpAbort:
+            if ((sd = a_Klist_get_data(ValidSocks, SKey))) {
+               const char *urlstr = URL_STR(sd->web->url);
+               MSG_BW(sd->web, 1, "Can't get %s", urlstr);
+               MSG("Query failed for %s\n", urlstr);
+            }
+            a_Chain_fcb(OpAbort, Info, NULL, "Both");
+            Http_socket_free(SKey);
+            dFree(Info);
+            break;
          default:
             MSG_WARN("Unused CCC\n");
             break;
diff -r c3a1c080990b src/cache.c
--- a/src/cache.c	Thu Jul 31 06:26:32 2014 +0000
+++ b/src/cache.c	Thu Jul 31 16:32:36 2014 +0000
@@ -974,8 +974,17 @@
    } else if (Op == IOClose) {
       Cache_finish_msg(entry);
    } else if (Op == IOAbort) {
-      /* unused */
-      MSG("a_Cache_process_dbuf Op = IOAbort; not implemented!\n");
+      int i;
+      CacheClient_t *Client;
+
+      for (i = 0; (Client = dList_nth_data(ClientQueue, i)); ++i) {
+         if (Client->Url == entry->Url) {
+            DilloWeb *web = (DilloWeb *)Client->Web;
+
+            a_Bw_remove_client(web->bw, Client->Key);
+            Cache_client_dequeue(Client);
+         }
+      }
    }
    return done;
 }
diff -r c3a1c080990b src/capi.c
--- a/src/capi.c	Thu Jul 31 06:26:32 2014 +0000
+++ b/src/capi.c	Thu Jul 31 16:32:36 2014 +0000
@@ -681,6 +681,7 @@
          case OpAbort:
             conn = Info->LocalKey;
             conn->InfoSend = NULL;
+            a_Cache_process_dbuf(IOAbort, NULL, 0, conn->url);
             if (Data2) {
                if (!strcmp(Data2, "DpidERROR")) {
                   a_UIcmd_set_msg(conn->bw,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.