about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorWilliam Wennerström <william@wstrm.dev>2020-12-10 19:26:06 +0100
committerWilliam Wennerström <william@wstrm.dev>2020-12-10 19:26:06 +0100
commit42a0518ff4e3dae48ba988c00299d92e1e2903c0 (patch)
tree41c7e732d4730e5739340bb4304015a01ca95c07 /src
parente70c64b74a0bd3f2dc9445a214888e5166a9c51d (diff)
downloadprofani-tty-42a0518ff4e3dae48ba988c00299d92e1e2903c0.tar.gz
Fix deadlock on error before HTTP download has begun
Diffstat (limited to 'src')
-rw-r--r--src/tools/http_download.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tools/http_download.c b/src/tools/http_download.c
index f97fd704..2ff49b61 100644
--- a/src/tools/http_download.c
+++ b/src/tools/http_download.c
@@ -123,7 +123,7 @@ http_file_get(void* userdata)
                                    "output file at '%s' for writing (%s).",
                                    download->url, download->filename,
                                    g_strerror(errno));
-        return NULL;
+        goto out;
     }
 
     char* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
@@ -185,9 +185,6 @@ http_file_get(void* userdata)
         }
     }
 
-    download_processes = g_slist_remove(download_processes, download);
-    pthread_mutex_unlock(&lock);
-
     if (download->cmd_template != NULL) {
         gchar** argv = format_call_external_argv(download->cmd_template,
                                                  download->url,
@@ -208,6 +205,11 @@ http_file_get(void* userdata)
         free(download->cmd_template);
     }
 
+out:
+
+    download_processes = g_slist_remove(download_processes, download);
+    pthread_mutex_unlock(&lock);
+
     free(download->url);
     free(download->filename);
     free(download);