merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:16 +0000 (01:12 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:16 +0000 (01:12 +0900)
CMakeLists.txt
include/download.h
packaging/capi-web-url-download.spec
src/download-wrapping.c [new file with mode: 0755]
src/download.c

index 727bbad..2cae7c1 100755 (executable)
@@ -12,7 +12,7 @@ SET(VERSION "${VERSION_MAJOR}.1.0")
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(requires "dlog capi-base-common capi-appfw-app-manager capi-appfw-application download-provider dbus-1")
+SET(requires "dlog capi-base-common download-provider-interface")
 MESSAGE(STATUS "PACKAGES : ${requires}")
 SET(pc_requires "capi-base-common capi-appfw-application")
 
@@ -35,7 +35,7 @@ ADD_DEFINITIONS(-DDP_SUPPORT_DBUS_ACTIVATION)
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
 
-SET(SOURCES src/download.c)
+SET(SOURCES src/download-wrapping.c)
 MESSAGE(STATUS "SOURCES : ${SOURCES}")
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
 
index ca8af1f..8006958 100755 (executable)
@@ -18,8 +18,6 @@
 #define __TIZEN_WEB_DOWNLOAD_H__
 
 #include <tizen.h>
-#include <app.h>
-
 
 #ifdef __cplusplus
 extern "C"
@@ -351,31 +349,46 @@ int download_get_notification(int download_id, bool *enable);
  *
  * @param[in] download The download id
  * @param[in] key The character pointer type. The extra param has a pair of key and value
- * @param[in] value The character pointer type. The extra param has a pair of key and value
+ * @param[in] values The character pointer array type. The extra param has a pair of key and value array
+ * @param[in] length The length of value array
  * @return 0 on success, otherwise a negative error value.
  * @retval #DOWNLOAD_ERROR_NONE Successful
  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
  * @see download_get_notification_extra_param()
- * @see download_service_get_extra_data()
- * @see service_get_operation()
+ * @see download_remove_notification_extra_param()
  */
-int download_set_notification_extra_param(int download_id, char *key, char *value);
+int download_add_notification_extra_param(int download_id, const char *key, const char **values, const unsigned int length);
 
+/**
+ * @brief Remove the extra param data which pass by application service data when notification message is clicked
+ *
+ * @remarks This function should be called before downloading (See download_start())
+ *
+ * @param[in] download The download id
+ * @param[in] key The character pointer type. The extra param has a pair of key and value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_add_notification_extra_param()
+ * @see download_get_notification_extra_param()
+ */
+int download_remove_notification_extra_param(int download_id, const char *key);
 
 /**
  * @brief Gets the extra param value to set by download_set_notification_extra_param
  * @param[in] download The download id
  * @param[out] key The character pointer type. The extra param has a pair of key and value
- * @param[out] value param The character pointer type. The extra param has a pair of key and value
+ * @param[out] values param The character pointer array type. The extra param has a pair of key and value array
+ * @param[out] length The length of value array
  * @return 0 on success, otherwise a negative error value.
  * @retval #DOWNLOAD_ERROR_NONE Successful
  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
  * @see download_set_notification_extra_param()
  */
-int download_get_notification_extra_param(int download_id, char **key, char **value);
-
+int download_get_notification_extra_param(int download_id, const char *key, char ***values, unsigned int *length);
 
 /**
  * @brief Gets the absolute path to save the downloaded file
index c9f5268..f401bb5 100755 (executable)
@@ -1,18 +1,15 @@
 
 Name:  capi-web-url-download
 Summary:       CAPI for content download with web url
-Version:       1.0.1
-Release:       6
+Version:       1.0.2
+Release:       3
 Group:         Development/Libraries
 License:       Apache License, Version 2.0
 URL:           N/A
 Source0:       %{name}-%{version}.tar.gz
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(download-provider)
-BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(download-provider-interface)
 BuildRequires: cmake
 
 %description
@@ -56,6 +53,17 @@ mkdir -p %{buildroot}/usr/share/license
 %{_includedir}/web/download.h
 
 %changelog
+* Tue Mar 05 2013 Jungki Kwak <jungki.kwak@samsung.com>
+- Changes APIs for notification extra list
+- Use download-provider-interface library
+
+* Sat Feb 23 2013 Kwangmin Bang <justine.bang@samsung.com>
+- do not close the socket in Interrupted System Call
+
+* Mon Feb 18 2013 Kwangmin Bang <justine.bang@samsung.com>
+- use invalid pointer
+- return wrong state in _download_change_dp_state()
+
 * Thu Jan 31 2013 Kwangmin Bang <justine.bang@samsung.com>
 - support new state of provider
 
diff --git a/src/download-wrapping.c b/src/download-wrapping.c
new file mode 100755 (executable)
index 0000000..aa54426
--- /dev/null
@@ -0,0 +1,305 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <dlog.h>
+#include <download.h>
+#include <download-provider-interface.h>
+
+#define DEBUG_MSG
+#ifdef DEBUG_MSG
+#include <dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_URL_DOWNLOAD"
+#define TRACE_ERROR(format, ARG...)  \
+{ \
+LOGE(format, ##ARG); \
+}
+#define TRACE_STRERROR(format, ARG...)  \
+{ \
+LOGE(format" [%s]", ##ARG, strerror(errno)); \
+}
+#define TRACE_INFO(format, ARG...)  \
+{ \
+LOGI(format, ##ARG); \
+}
+#else
+#define TRACE_DEBUG_MSG(format, ARG...) ;
+#endif
+
+/////////////////////// APIs /////////////////////////////////
+
+int download_create(int *download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_create(download_id);
+}
+
+int download_destroy(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_destroy(download_id);
+}
+
+int download_start(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_start(download_id);
+}
+
+int download_pause(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_pause(download_id);
+}
+
+int download_cancel(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_cancel(download_id);
+}
+
+
+int download_set_url(int download_id, const char *url)
+{
+       TRACE_INFO("");
+       return dp_interface_set_url(download_id, url);
+}
+
+
+int download_get_url(int download_id, char **url)
+{
+       TRACE_INFO("");
+       return dp_interface_get_url(download_id, url);
+}
+
+int download_set_network_type(int download_id,
+                                               download_network_type_e net_type)
+{
+       TRACE_INFO("");
+       return dp_interface_set_network_type(download_id, (int)net_type);
+}
+
+int download_get_network_type(int download_id,
+                                                       download_network_type_e *net_type)
+{
+       TRACE_INFO("");
+
+       int network_type = DOWNLOAD_ADAPTOR_NETWORK_ALL;
+       int ret = dp_interface_get_network_type(download_id, &network_type);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *net_type = network_type;
+       return ret;
+}
+
+int download_set_destination(int download_id, const char *path)
+{
+       TRACE_INFO("");
+       return dp_interface_set_destination(download_id, path);
+}
+
+
+int download_get_destination(int download_id, char **path)
+{
+       TRACE_INFO("");
+       return dp_interface_get_destination(download_id, path);
+}
+
+int download_set_file_name(int download_id, const char *file_name)
+{
+       TRACE_INFO("");
+       return dp_interface_set_file_name(download_id, file_name);
+}
+
+int download_get_file_name(int download_id, char **file_name)
+{
+       TRACE_INFO("");
+       return dp_interface_get_file_name(download_id, file_name);
+}
+
+int download_set_ongoing_notification(int download_id, bool enable)
+{
+       return download_set_notification(download_id, enable);
+}
+
+int download_set_notification(int download_id, bool enable)
+{
+       TRACE_INFO("");
+       return dp_interface_set_notification(download_id, (int)enable);
+}
+
+int download_get_ongoing_notification(int download_id, bool *enable)
+{
+       return download_get_notification(download_id, enable);
+}
+
+int download_get_notification(int download_id, bool *enable)
+{
+       int is_set = 0;
+
+       TRACE_INFO("");
+       int ret = dp_interface_get_notification(download_id, &is_set);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *enable = (bool)is_set;
+       return ret;
+}
+
+int download_get_downloaded_file_path(int download_id, char **path)
+{
+       TRACE_INFO("");
+       return dp_interface_get_downloaded_file_path(download_id, path);
+}
+
+int download_add_notification_extra_param(
+               int download_id, const char *key,
+               const char **value, const unsigned int length)
+{
+       TRACE_INFO("");
+       return dp_interface_add_noti_extra(download_id, key, value, length);
+}
+
+int download_remove_notification_extra_param(int download_id, const char *key)
+{
+       TRACE_INFO("");
+       return dp_interface_remove_noti_extra_key(download_id, key);
+}
+
+int download_get_notification_extra_param(
+               int download_id, const char *key,
+               char ***values, unsigned int *length)
+{
+       TRACE_INFO("");
+       return dp_interface_get_noti_extra_values(download_id, key, values, length);
+}
+
+int download_add_http_header_field(int download_id, const char *field,
+       const char *value)
+{
+       TRACE_INFO("");
+       return
+               dp_interface_add_http_header_field(download_id, field, value);
+}
+
+int download_get_http_header_field(int download_id,
+       const char *field, char **value)
+{
+       TRACE_INFO("");
+       return
+               dp_interface_get_http_header_field(download_id, field, value);
+}
+
+int download_remove_http_header_field(int download_id,
+       const char *field)
+{
+       TRACE_INFO("");
+       return dp_interface_remove_http_header_field(download_id, field);
+}
+
+// download_state_changed_cb is different with dp_interface_state_changed_cb.
+int download_set_state_changed_cb(int download_id,
+       download_state_changed_cb callback, void* user_data)
+{
+       TRACE_INFO("");
+       return dp_interface_set_state_changed_cb(download_id,
+               (dp_interface_state_changed_cb)callback, user_data);
+}
+
+int download_unset_state_changed_cb(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_unset_state_changed_cb(download_id);
+}
+
+// download_progress_cb is same with dp_interface_progress_cb.
+int download_set_progress_cb(int download_id,
+       download_progress_cb callback, void *user_data)
+{
+       TRACE_INFO("");
+       return dp_interface_set_progress_cb(download_id,
+                       (dp_interface_progress_cb)callback, user_data);
+}
+
+int download_unset_progress_cb(int download_id)
+{
+       TRACE_INFO("");
+       return dp_interface_unset_progress_cb(download_id);
+}
+
+int download_get_state(int download_id, download_state_e *state)
+{
+       int statecode = 0;
+
+       TRACE_INFO("");
+       int ret = dp_interface_get_state(download_id, &statecode);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *state = statecode;
+       return ret;
+}
+
+int download_get_temp_path(int download_id, char **temp_path)
+{
+       TRACE_INFO("");
+       return dp_interface_get_temp_path(download_id, temp_path);
+}
+
+int download_get_content_name(int download_id, char **content_name)
+{
+       TRACE_INFO("");
+       return dp_interface_get_content_name(download_id, content_name);
+}
+
+int download_get_content_size(int download_id,
+       unsigned long long *content_size)
+{
+       TRACE_INFO("");
+       return dp_interface_get_content_size(download_id, content_size);
+}
+
+int download_get_mime_type(int download_id, char **mime_type)
+{
+       TRACE_INFO("");
+       return dp_interface_get_mime_type(download_id, mime_type);
+}
+
+int download_set_auto_download(int download_id, bool enable)
+{
+       TRACE_INFO("");
+       return dp_interface_set_auto_download(download_id, (int)enable);
+}
+
+int download_get_auto_download(int download_id, bool *enable)
+{
+       int is_set = 0;
+
+       TRACE_INFO("");
+       int ret = dp_interface_get_auto_download(download_id, &is_set);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *enable = (bool)is_set;
+       return ret;
+}
+
+int download_get_error(int download_id, download_error_e *error)
+{
+       int errorcode = 0;
+
+       TRACE_INFO("");
+       int ret = dp_interface_get_error(download_id, &errorcode);
+       if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+               *error = errorcode;
+       return ret;
+}
+
+int download_get_http_status(int download_id, int *http_status)
+{
+       TRACE_INFO("");
+       return dp_interface_get_http_status(download_id, http_status);
+}
+
index 5990018..47cca05 100755 (executable)
 #include <download.h>
 #include <download-provider.h>
 
-#ifdef DP_ECHO_TEST
-#define DOWNLOAD_ECHO_SUPPORT
+#ifdef DP_DBUS_ACTIVATION
+#include <dbus/dbus.h>
 #endif
-#ifdef DOWNLOAD_ECHO_SUPPORT
+
+#ifdef DP_ECHO_TEST
 #include <sys/ioctl.h>
 #endif
 
-#ifdef DP_DBUS_ACTIVATION
-#include <dbus/dbus.h>
-#endif
+#define DP_CHECK_PROVIDER_STATUS do {\
+       if (__check_ipc_status(g_download_ipc->cmd_socket) < 0) {\
+               pthread_mutex_unlock((&g_download_ipc->mutex));\
+               pthread_mutex_unlock(&g_download_mutex);\
+               if (errno != EAGAIN && errno != EINTR)\
+                       _disconnect_from_provider();\
+               return DOWNLOAD_ERROR_IO_ERROR;\
+       }\
+} while(0)
 
 #define MAX_DOWNLOAD_HANDLE 5
 
@@ -220,7 +227,7 @@ int _download_change_dp_state(int state)
        default:
                break;
        }
-       return DOWNLOAD_ERROR_NONE;
+       return DOWNLOAD_STATE_NONE;
 }
 
 void _download_print_str_state(int state)
@@ -385,7 +392,11 @@ download_error_e _download_ipc_read_return(int fd)
                if (errno == EPIPE) {
                        TRACE_INFO("[EPIPE] Broken Pipe errno [%d]", errno);
                } else if (errno == EAGAIN) {
-                       TRACE_INFO("[EAGAIN] Resource temporarily unavailable errno [%d]", errno);
+                       TRACE_INFO
+                               ("[EAGAIN] Resource temporarily unavailable errno [%d]",
+                               errno);
+               } else if (errno == EINTR) {
+                       TRACE_ERROR("[EINTR] Interrupted System Call");
                } else {
                        TRACE_INFO("errno [%d]", errno);
                }
@@ -599,9 +610,9 @@ int _disconnect_from_provider()
        return DOWNLOAD_ERROR_NONE;
 }
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
+#ifdef DP_ECHO_TEST
 // clear read buffer. call in head of API before calling IPC_SEND
-void __clear_read_buffer(int fd)
+static void __clear_read_buffer(int fd)
 {
        long i;
        long unread_count;
@@ -620,15 +631,15 @@ void __clear_read_buffer(int fd)
                }
        }
 }
+#endif
 
 // ask to provider before sending a command.
 // if provider wait in some commnad, can not response immediately
 // capi will wait in read block.
 // after asking, call clear_read_buffer.
-
-
-int _check_ipc_status(int fd)
+static int __check_ipc_status(int fd)
 {
+#ifdef DP_ECHO_TEST
        // echo from provider
        download_error_e errorcode = _send_simple_cmd(-1, DP_CMD_ECHO);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
@@ -638,15 +649,14 @@ int _check_ipc_status(int fd)
                                TRACE_INFO("[EAGAIN] provider is busy");
                        } else {
                                TRACE_INFO("[CRITICAL] Broken Socket");
-                               _disconnect_from_provider();
                        }
                        return -1;
                }
        }
        __clear_read_buffer(fd);
+#endif
        return 0;
 }
-#endif
 
 // listen ASYNC state event, no timeout
 void *_download_event_manager(void *arg)
@@ -706,7 +716,7 @@ void *_download_event_manager(void *arg)
                                        free(eventinfo);
                                TRACE_STRERROR("[CRITICAL] Can not read Event packet");
                                pthread_mutex_unlock(&g_download_mutex);
-                               if (errno != EAGAIN) // if not timeout. end thread
+                               if (errno != EAGAIN && errno != EINTR) // if not timeout. end thread
                                        break;
                                continue;
                        }
@@ -918,19 +928,15 @@ int download_create(int *download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(-1, DP_CMD_CREATE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -939,7 +945,7 @@ int download_create(int *download_id)
        t_download_id = _download_ipc_read_int(g_download_ipc->cmd_socket);
        if (t_download_id < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -974,13 +980,7 @@ int download_destroy(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        index = _get_my_slot_index(download_id);
        if (index >= 0) {
@@ -993,8 +993,10 @@ int download_destroy(int download_id)
        errorcode = _send_simple_cmd(download_id, DP_CMD_DESTROY);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1036,19 +1038,15 @@ int download_start(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_START);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1076,19 +1074,15 @@ int download_pause(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_PAUSE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1116,19 +1110,15 @@ int download_cancel(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_CANCEL);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1159,13 +1149,7 @@ int download_set_url(int download_id, const char *url)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -1191,7 +1175,7 @@ int download_set_url(int download_id, const char *url)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1222,19 +1206,15 @@ int download_get_url(int download_id, char **url)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_URL);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1242,7 +1222,7 @@ int download_get_url(int download_id, char **url)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1280,13 +1260,7 @@ int download_set_network_type(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        if (_download_ipc_send_command(g_download_ipc->cmd_socket,
                download_id, DP_CMD_SET_NETWORK_TYPE)
@@ -1310,7 +1284,7 @@ int download_set_network_type(int download_id,
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1341,19 +1315,15 @@ int download_get_network_type(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_NETWORK_TYPE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1361,7 +1331,7 @@ int download_get_network_type(int download_id,
        network_type = _download_ipc_read_int(g_download_ipc->cmd_socket);
        if (network_type < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1401,13 +1371,7 @@ int download_set_destination(int download_id, const char *path)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -1433,7 +1397,7 @@ int download_set_destination(int download_id, const char *path)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1464,20 +1428,16 @@ int download_get_destination(int download_id, char **path)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode =
                _send_simple_cmd(download_id, DP_CMD_GET_DESTINATION);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1485,7 +1445,7 @@ int download_get_destination(int download_id, char **path)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1519,13 +1479,7 @@ int download_set_file_name(int download_id, const char *file_name)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -1551,7 +1505,7 @@ int download_set_file_name(int download_id, const char *file_name)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1581,20 +1535,16 @@ int download_get_file_name(int download_id, char **file_name)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode =
                _send_simple_cmd(download_id, DP_CMD_GET_FILENAME);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1602,7 +1552,7 @@ int download_get_file_name(int download_id, char **file_name)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1639,13 +1589,7 @@ int download_set_notification(int download_id, bool enable)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        if (_download_ipc_send_command(g_download_ipc->cmd_socket,
                download_id, DP_CMD_SET_NOTIFICATION)
@@ -1669,7 +1613,7 @@ int download_set_notification(int download_id, bool enable)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1704,26 +1648,22 @@ int download_get_notification(int download_id, bool *enable)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_NOTIFICATION);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
        value = _download_ipc_read_int(g_download_ipc->cmd_socket);
        if (value < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1756,20 +1696,16 @@ int download_get_downloaded_file_path(int download_id, char **path)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode =
                _send_simple_cmd(download_id, DP_CMD_GET_SAVED_PATH);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1777,7 +1713,7 @@ int download_get_downloaded_file_path(int download_id, char **path)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1811,13 +1747,7 @@ int download_set_notification_extra_param(int download_id, char *key, char *valu
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -1853,7 +1783,7 @@ int download_set_notification_extra_param(int download_id, char *key, char *valu
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -1884,19 +1814,15 @@ int download_get_notification_extra_param(int download_id, char **key, char **va
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_EXTRA_PARAM);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -1904,7 +1830,7 @@ int download_get_notification_extra_param(int download_id, char **key, char **va
        key_str = _ipc_read_string(g_download_ipc->cmd_socket);
        if (key_str == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -1913,7 +1839,7 @@ int download_get_notification_extra_param(int download_id, char **key, char **va
        value_str = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value_str == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                free(key_str);
@@ -1953,13 +1879,7 @@ int download_add_http_header_field(int download_id, const char *field,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -1995,7 +1915,7 @@ int download_add_http_header_field(int download_id, const char *field,
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2031,13 +1951,7 @@ int download_get_http_header_field(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        if (_download_ipc_send_command
                (g_download_ipc->cmd_socket, download_id, DP_CMD_GET_HTTP_HEADER)
@@ -2063,7 +1977,7 @@ int download_get_http_header_field(int download_id,
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2073,7 +1987,7 @@ int download_get_http_header_field(int download_id,
        str = _ipc_read_string(g_download_ipc->cmd_socket);
        if (str == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2111,13 +2025,7 @@ int download_remove_http_header_field(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // send commnad with ID
        if (_download_ipc_send_command
@@ -2143,7 +2051,7 @@ int download_remove_http_header_field(int download_id,
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2179,13 +2087,8 @@ int download_set_state_changed_cb(int download_id,
        // turn on state_cb flag of provider
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
+
        // send create command.
        if (_download_ipc_send_command(g_download_ipc->cmd_socket,
                download_id, DP_CMD_SET_STATE_CALLBACK)
@@ -2258,13 +2161,7 @@ int download_unset_state_changed_cb(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        index = _get_my_slot_index(download_id);
        if (index >= 0) {
@@ -2296,7 +2193,7 @@ int download_unset_state_changed_cb(int download_id)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2330,13 +2227,7 @@ int download_set_progress_cb(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        // turn on progress_cb flag of provider
        // send create command.
@@ -2365,7 +2256,7 @@ int download_set_progress_cb(int download_id,
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                download_unset_progress_cb(download_id);
@@ -2412,13 +2303,7 @@ int download_unset_progress_cb(int download_id)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        index = _get_my_slot_index(download_id);
        if (index >= 0) {
@@ -2450,7 +2335,7 @@ int download_unset_progress_cb(int download_id)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2480,19 +2365,15 @@ int download_get_state(int download_id, download_state_e *state)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_STATE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2500,7 +2381,7 @@ int download_get_state(int download_id, download_state_e *state)
        if (_ipc_read_custom_type(g_download_ipc->cmd_socket,
                                                        &dp_state, sizeof(dp_state_type)) < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2534,20 +2415,16 @@ int download_get_temp_path(int download_id, char **temp_path)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode =
                _send_simple_cmd(download_id, DP_CMD_GET_TEMP_SAVED_PATH);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2555,7 +2432,7 @@ int download_get_temp_path(int download_id, char **temp_path)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2588,19 +2465,15 @@ int download_get_content_name(int download_id, char **content_name)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_CONTENT_NAME);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2608,7 +2481,7 @@ int download_get_content_name(int download_id, char **content_name)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2641,13 +2514,7 @@ int download_get_content_size(int download_id,
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_TOTAL_FILE_SIZE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
@@ -2663,7 +2530,7 @@ int download_get_content_size(int download_id,
                content_size, sizeof(unsigned long long));
        if (errorcode < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2694,19 +2561,15 @@ int download_get_mime_type(int download_id, char **mime_type)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_MIME_TYPE);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2714,7 +2577,7 @@ int download_get_mime_type(int download_id, char **mime_type)
        value = _ipc_read_string(g_download_ipc->cmd_socket);
        if (value == NULL) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2746,13 +2609,7 @@ int download_set_auto_download(int download_id, bool enable)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        if (_download_ipc_send_command(g_download_ipc->cmd_socket,
                download_id, DP_CMD_SET_AUTO_DOWNLOAD)
@@ -2776,7 +2633,7 @@ int download_set_auto_download(int download_id, bool enable)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2806,19 +2663,15 @@ int download_get_auto_download(int download_id, bool *enable)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_AUTO_DOWNLOAD);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2826,7 +2679,7 @@ int download_get_auto_download(int download_id, bool *enable)
        value = _download_ipc_read_int(g_download_ipc->cmd_socket);
        if (value < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;
@@ -2857,19 +2710,15 @@ int download_get_error(int download_id, download_error_e *error)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_ERROR);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2879,7 +2728,7 @@ int download_get_error(int download_id, download_error_e *error)
        if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
                TRACE_ERROR("[CHECK IO] (%d)", download_id);
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
@@ -2911,19 +2760,15 @@ int download_get_http_status(int download_id, int *http_status)
 
        pthread_mutex_lock((&g_download_ipc->mutex));
 
-#ifdef DOWNLOAD_ECHO_SUPPORT
-       if (_check_ipc_status(g_download_ipc->cmd_socket) < 0) {
-               pthread_mutex_unlock((&g_download_ipc->mutex));
-               pthread_mutex_unlock(&g_download_mutex);
-               return DOWNLOAD_ERROR_IO_ERROR;
-       }
-#endif
+       DP_CHECK_PROVIDER_STATUS;
 
        errorcode = _send_simple_cmd(download_id, DP_CMD_GET_HTTP_STATUS);
        if (errorcode != DOWNLOAD_ERROR_NONE) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errorcode == DOWNLOAD_ERROR_IO_ERROR && errno != EAGAIN)
-                       _disconnect_from_provider();
+               if (errorcode == DOWNLOAD_ERROR_IO_ERROR) {
+                       if (errno != EAGAIN && errno != EINTR)
+                               _disconnect_from_provider();
+               }
                pthread_mutex_unlock(&g_download_mutex);
                return errorcode;
        }
@@ -2931,7 +2776,7 @@ int download_get_http_status(int download_id, int *http_status)
        status = _download_ipc_read_int(g_download_ipc->cmd_socket);
        if (status < 0) {
                pthread_mutex_unlock((&g_download_ipc->mutex));
-               if (errno != EAGAIN)
+               if (errno != EAGAIN && errno != EINTR)
                        _disconnect_from_provider();
                pthread_mutex_unlock(&g_download_mutex);
                return DOWNLOAD_ERROR_IO_ERROR;