diff options
author | jcid <devnull@localhost> | 2008-04-11 21:45:14 +0200 |
---|---|---|
committer | jcid <devnull@localhost> | 2008-04-11 21:45:14 +0200 |
commit | f979c87530c232bf7d9f4b97d1917ad8ab22b502 (patch) | |
tree | b2cc77ea56250c89eca8df6aadd27c9d7dec942f | |
parent | cac859fe118a523edc80f745ed57d49568fc0b2d (diff) |
- Fixed a cookies-related dillo freeze bug happening at:
http://www.fltk.org/newsgroups.php?gfltk.general+v:24912
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | dpi/cookies.c | 23 | ||||
-rw-r--r-- | src/IO/http.c | 2 | ||||
-rw-r--r-- | src/cookies.c | 14 |
4 files changed, 30 insertions, 12 deletions
@@ -102,6 +102,9 @@ dillo-fltk2 - Added a_Capi_get_flags(). It requests a cache entry's status as flags. - Switched URL_DATA type from char* to a dStr. Patch: place, Jorge Arellano Cid ++- Fixed a cookies-related dillo freeze bug happening at: + http://www.fltk.org/newsgroups.php?gfltk.general+v:24912 + Patch: Andreas Kemnade, Jorge Arellano Cid +- Fixed a va_list-related SEGFAULT on 64bit-arch in dStr_vsprintfa(). Added const declarations in html parser. Patch: Vincent Thomasset diff --git a/dpi/cookies.c b/dpi/cookies.c index d4d87698..0a3b37d1 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -195,14 +195,16 @@ static FILE *Cookies_fopen(const char *filename, char *init_str) close(fd); MSG("Created file: %s\n", filename); - F_in = Cookies_fopen(filename, NULL); + F_in = fopen(filename, "r+"); } else { MSG("Could not create file: %s!\n", filename); } } - /* set close on exec */ - fcntl(fileno(F_in), F_SETFD, FD_CLOEXEC | fcntl(fileno(F_in), F_GETFD)); + if (F_in) { + /* set close on exec */ + fcntl(fileno(F_in), F_SETFD, FD_CLOEXEC | fcntl(fileno(F_in), F_GETFD)); + } return F_in; } @@ -1327,7 +1329,7 @@ static CookieControlAction Cookies_control_check_domain(const char *domain) static int srv_parse_buf(SockHandler *sh, char *Buf, size_t BufSize) { char *p, *cmd, *cookie, *host, *path, *scheme; - int port; + int port, ret; if (!(p = strchr(Buf, '>'))) { /* Haven't got a full tag */ @@ -1375,14 +1377,15 @@ static int srv_parse_buf(SockHandler *sh, char *Buf, size_t BufSize) cmd = a_Dpip_build_cmd("cmd=%s cookie=%s", "get_cookie_answer", cookie); if (sock_handler_write_str(sh, 1, cmd)) { - dFree(cookie); - dFree(cmd); - return 1; + ret = 1; + } else { + _MSG("sock_handler_write_str: SUCCESS cmd={%s}\n", cmd); + ret = 2; } dFree(cookie); dFree(cmd); - return 2; + return ret; } return 0; @@ -1455,8 +1458,10 @@ int main (void) { code = 1; if ((buf = sock_handler_read(sh)) != NULL) { /* Let's see what we fished... */ + _MSG(" buf = {%s}\n", buf); code = srv_parse_buf(sh, buf, strlen(buf)); } + _MSG(" code = %d %s\n", code, code == 1 ? "EXIT" : "BREAK"); if (code == 1) exit(1); else if (code == 2) @@ -1468,6 +1473,8 @@ int main (void) { sock_handler_free(sh); }/*while*/ + + return 0; } #endif /* !DISABLE_COOKIES */ diff --git a/src/IO/http.c b/src/IO/http.c index a6acc031..00ccc0e6 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -278,7 +278,7 @@ Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy) dStr_free(s_port, TRUE); dStr_free(full_path, TRUE); dStr_free(proxy_auth, TRUE); - DEBUG_MSG(4, "Query:\n%s\n", dStr_printable(query, 8192)); + _MSG("Query: {%s}\n", dStr_printable(query, 8192)); return query; } diff --git a/src/cookies.c b/src/cookies.c index 4acb4c7f..20b166fd 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -95,7 +95,7 @@ static FILE *Cookies_fopen(const char *filename, char *init_str) close(fd); DEBUG_MSG(10, "Cookies: Created file: %s\n", filename); - F_in = Cookies_fopen(filename, NULL); + F_in = fopen(filename, "r"); } else { DEBUG_MSG(10, "Cookies: Could not create file: %s!\n", filename); } @@ -141,7 +141,7 @@ void a_Cookies_freeall() void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url) { CookieControlAction action; - char *cmd, *cookie_string, numstr[16]; + char *cmd, *cookie_string, *dpip_tag, numstr[16]; const char *path; int i; @@ -162,7 +162,13 @@ void a_Cookies_set(Dlist *cookie_strings, const DilloUrl *set_url) path ? path : "/", numstr); DEBUG_MSG(5, "Cookies.c: a_Cookies_set \n\t \"%s\" \n",cmd ); - a_Capi_dpi_send_cmd(NULL, NULL, cmd, "cookies", 1); + /* This call is commented because it doesn't guarantee the order + * in which cookies are set and got. (It may deadlock too) */ + //a_Capi_dpi_send_cmd(NULL, NULL, cmd, "cookies", 1); + + dpip_tag = a_Dpi_send_blocking_cmd("cookies", cmd); + _MSG("a_Cookies_set: dpip_tag = {%s}\n", dpip_tag); + dFree(dpip_tag); dFree(cmd); } } @@ -192,7 +198,9 @@ char *a_Cookies_get_query(const DilloUrl *request_url) URL_HOST(request_url), path ? path : "/", numstr); /* Get the answer from cookies.dpi */ + _MSG("cookies.c: a_Dpi_send_blocking_cmd cmd = {%s}\n", cmd); dpip_tag = a_Dpi_send_blocking_cmd("cookies", cmd); + _MSG("cookies.c: after a_Dpi_send_blocking_cmd resp={%s}\n", dpip_tag); dFree(cmd); query = dStrdup("Cookie2: $Version=\"1\"\r\n"); |