bitbake: fetch/wget: checkstatus: drop shared connecton when catch Timeout error

* to avoid wrong http response in checkstatus function:
   in wget checkstatus() we are using 'HTTPConnectionCache' to share connections
   1. state_file1(exists on http server) use shared connection <shared1> to send request
   2. http_server recieved request of state_file1, but delayed by some reason to sent respone
   3. state_file1 checkstatus() failed by timeout and drop shared connection <shared1>
   4. state_file2(not exists on http server) get shared connection <shared1> and send request
   5. http_server finally send 200 response for state_file1
   6. state_file2 recived 200 response and thought it was exists on http_server

(Bitbake rev: bf6d0282ab88b4edc4b9e58184cd76cce965abbd)

Signed-off-by: y75zhang <yang-mark.zhang@nokia-sbell.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
y75zhang
2024-07-03 08:20:34 +03:00
committed by Richard Purdie
parent 72a9b812c9
commit 4172c3bdd5

View File

@@ -244,7 +244,12 @@ class Wget(FetchMethod):
fetch.connection_cache.remove_connection(h.host, h.port)
raise urllib.error.URLError(err)
else:
r = h.getresponse()
try:
r = h.getresponse()
except TimeoutError as e:
if fetch.connection_cache:
fetch.connection_cache.remove_connection(h.host, h.port)
raise TimeoutError(e)
# Pick apart the HTTPResponse object to get the addinfourl
# object initialized properly.