curl: transfer hangs in case connection was cut between client and server
authorImre Eörs <imree@axis.com>
Tue, 15 Nov 2016 15:20:10 +0000 (16:20 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 16 Nov 2016 09:19:45 +0000 (09:19 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=774485

ext/curl/gstcurlbasesink.c

index 5728ab2..40c6182 100644 (file)
@@ -705,6 +705,21 @@ gst_curl_base_sink_transfer_set_common_options_unlocked (GstCurlBaseSink * sink)
         curl_easy_strerror (res));
     return FALSE;
   }
+  /* Time out in case transfer speed in bytes per second stay below
+   * CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME */
+  res = curl_easy_setopt (sink->curl, CURLOPT_LOW_SPEED_LIMIT, 1L);
+  if (res != CURLE_OK) {
+    sink->error = g_strdup_printf ("failed to set low speed limit: %s",
+        curl_easy_strerror (res));
+    return FALSE;
+  }
+  res = curl_easy_setopt (sink->curl, CURLOPT_LOW_SPEED_TIME,
+      (long)sink->timeout);
+  if (res != CURLE_OK) {
+    sink->error = g_strdup_printf ("failed to set low speed time: %s",
+        curl_easy_strerror (res));
+    return FALSE;
+  }
 
   GST_LOG ("common options set");
   return TRUE;