altsvc: make saving the cache an atomic operation

... by writing the file to temp name then rename to the final when done.

Assisted-by: Jay Satiro
Fixes #4936
Closes #4942
This commit is contained in:
Daniel Stenberg 2020-02-17 23:01:48 +01:00
parent 330f133224
commit 14916a82e2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 41 additions and 19 deletions

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -124,7 +124,7 @@ UNITTEST_START
}
fail_unless(asi->num == 10, "wrong number of entries");
Curl_altsvc_save(asi, outname);
Curl_altsvc_save(curl, asi, outname);
curl_easy_cleanup(curl);
fail: