Fix segfault in ccurl_thread.c
[monky] / src / ccurl_thread.c
index d69e860..f52a654 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Please see COPYING for details
  *
- * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
@@ -133,9 +133,15 @@ void ccurl_fetch_data(ccurl_location_t *curloc)
 
                res = curl_easy_perform(curl);
                if (res == CURLE_OK && chunk.size) {
-                       timed_thread_lock(curloc->p_timed_thread);
-                       (*curloc->process_function)(curloc->result, chunk.memory);
-                       timed_thread_unlock(curloc->p_timed_thread);
+                       long http_status_code;
+
+                       if(curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status_code) == CURLE_OK && http_status_code == 200) {
+                               timed_thread_lock(curloc->p_timed_thread);
+                               (*curloc->process_function)(curloc->result, chunk.memory);
+                               timed_thread_unlock(curloc->p_timed_thread);
+                       } else {
+                               NORM_ERR("curl: no data from server");
+                       }
                        free(chunk.memory);
                } else {
                        NORM_ERR("curl: no data from server");