bugGNU Wget - Bugs: bug #58050, Incorrect timeout handling when...

 
 

bug #58050: Incorrect timeout handling when tls transport is registered

Submitter:  Vyacheslav <vyacheslav>
Submitted:  Thu 26 Mar 2020 08:46:16 AM UTC
   
 
Category:  Program Logic Severity:  3 - Normal
Priority:  5 - Normal Status:  Fixed
Privacy:  Public Assigned to:  rockdaboot
Originator Name:  Open/Closed:  Closed
Release:  trunk Operating System:  None
Reproducibility:  None Fixed Release:  1.20
Planned Release:  None Regression:  None
Work Required:  None Patch Included:  Yes
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 31 Jan 2021 04:31:14 PM UTC, comment #3: 
Tim Ruehsen <rockdaboot>
Group administrator
Fri 01 May 2020 03:56:31 PM UTC, comment #2: 

Thanks, pushed.

Tim Ruehsen <rockdaboot>
Group administrator
Sun 26 Apr 2020 06:35:43 PM UTC, comment #1: 

Thanks for this patchset!

I have extracted a part of the original patchset to fix hangs in openssl_peek with only minimal changes (see attachment).

I have only tested it so far in combination with wget-lua [1].

[1] https://github.com/TailR3d/wget-lua/commit/61776707506e4feeb04c48bebdb049d212cdfbbe

(file #48943)

Anonymous
Thu 26 Mar 2020 08:46:16 AM UTC, original submission:  

A few fixes are required:
a) for now, according to the implementation of fd_read() fd_peek() (when tls transport is registered) in the worst case real timeout may be 2*timeout.
(first wait when calling poll_internal(), second wait in info->imp->reader)

b) blocking/non-blocking conversion in gnutls.c (wgnutls_read_timeout) for MSWin
(select_fd, _do_handshake, _do_reauth will set mode back to blocked).

c) openssl.c (openssl_read) uses run_with_timeout. In case  MSWin this means that Wget will CreateThread() for each read and will call TerminateThread() if timeout occurs. if CreateThread() just a system load (small, but useless), then the TerminateThread() is dangerous and not recommended by MS, it should be used only if we know exactly what the thread is doing at this time.
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-terminatethread
(you can try to run Wget with very small timeout (0.01 for me) in 50% cases Wget will hang at 'connect to ip' and only 'terminate process' will help)

I made some changes that allow:

(the main thing)
a) more accurate timeout handling when tls transport registered;
b) do not use run_with_timeout (openssl.c) for each reading;
c) fix for conversion to blocked/non-blocked;

(another thing)
Bar progress set as 'interactive' (speed, eta will be every 1s, 'even when the data arrives very slowly or stalls'). No new, retr.c supports it.

Vyacheslav <vyacheslav>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48679:  read-timeout-handling.tar.xz added by vyacheslav (9KiB - application/x-xz)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rockdaboot (Posted a comment)
  • -email is unavailable- added by vyacheslav (Submitted the item)
  •  

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-31 rockdaboot StatusNone Fixed
        Assigned toNone rockdaboot
        Open/ClosedOpen Closed
        Fixed ReleaseNone 1.20
    2020-04-26 None Attached File- Added 0001-src-openssl.c-openssl_peek-Fix-hangs-beyond-read_tim.patch, #48943
    2020-03-26 vyacheslav Attached File- Added read-timeout-handling.tar.xz, #48679

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code