Add critical section to avoid thread safety issue
[platform/core/uifw/stt.git] / client / stt_file.c
old mode 100644 (file)
new mode 100755 (executable)
index e95b3c3..030829f
@@ -250,7 +250,7 @@ static sttengine_info_s* __stt_file_get_engine_by_id(int engine_id)
        return NULL;
 }
 
-void __stt_file_result_cb(stte_result_event_e event, const char* type, const char** data, int data_count,
+int __stt_file_result_cb(stte_result_event_e event, const char* type, const char** data, int data_count,
                 const char* msg, void* time_info, void *user_data)
 {
 
@@ -270,7 +270,7 @@ void __stt_file_result_cb(stte_result_event_e event, const char* type, const cha
        /* check handle */
        if (NULL == client) {
                SLOG(LOG_ERROR, TAG_STTFC, "[ERROR] Fail to notify error : A handle is not valid");
-               return;
+               return STT_FILE_ERROR_OPERATION_FAILED;
        }
 
        if (NULL != time_info) {
@@ -304,7 +304,7 @@ void __stt_file_result_cb(stte_result_event_e event, const char* type, const cha
                }
        }
 
-       return;
+       return STT_FILE_ERROR_NONE;
 }
 
 void __stt_file_speech_status_cb(stte_speech_status_e status, void *user_data)
@@ -359,18 +359,16 @@ int stt_file_initialize(void)
        /* Get file name from default engine directory */
        DIR *dp = NULL;
        int ret = -1;
-       struct dirent entry;
        struct dirent *dirp = NULL;
        dp  = opendir(STT_DEFAULT_ENGINE);
        if (NULL != dp) {
                do {
-                       ret = readdir_r(dp, &entry, &dirp);
-                       if (0 != ret) {
-                               SLOG(LOG_ERROR, TAG_STTFC, "[File ERROR] Fail to read directory");
-                               break;
-                       }
+                       dirp = readdir(dp);
 
                        if (NULL != dirp) {
+                               if (!strcmp(".", dirp->d_name) || !strcmp("..", dirp->d_name))
+                                       continue;
+
                                sttengine_info_s* info = NULL;
                                char* filepath;
                                int filesize;