thumb_err("_media_thumb_process is failed: %d", err);
res_msg->status = THUMB_FAIL;
} else {
- thumb_warn("_media_thumb_process is failed: %d, So use default thumb", err);
- res_msg->status = THUMB_SUCCESS;
+ if (err != MS_MEDIA_ERR_FILE_NOT_EXIST) {
+ thumb_warn("_media_thumb_process is failed: %d, So use default thumb", err);
+ res_msg->status = THUMB_SUCCESS;
+ } else {
+ thumb_warn("_media_thumb_process is failed: %d, (file not exist) ", err);
+ res_msg->status = THUMB_FAIL;
+ }
}
} else {
res_msg->status = THUMB_SUCCESS;
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, default_path, max_length);
free(default_path);
+ default_path = NULL;
}
_media_thumb_db_disconnect();
return err;
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, default_path, max_length);
free(default_path);
+ default_path = NULL;
}
_media_thumb_db_disconnect();
return err;
if(default_path) {
strncpy(thumb_path, default_path, max_length);
free(default_path);
+ default_path = NULL;
}
goto DB_UPDATE;
// _media_thumb_db_disconnect();
if(default_path) {
strncpy(thumb_path, default_path, max_length);
free(default_path);
+ default_path = NULL;
}
}
_media_thumb_db_disconnect();
#include <pwd.h>
#define THUMB_SOCK_BLOCK_SIZE 512
+#define THUMB_IPC_PATH "/var/run/media-server/media_ipc_thumbcreator.socket"
static GQueue *g_request_queue = NULL;
static GQueue *g_manage_queue = NULL;
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
+ strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
thumb_dbg_slog("Path : %s", origin_path);
thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData));
+ if (userData == NULL) {
+ thumb_err("memory allocation failed");
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
+ }
userData->func = (ThumbFunc)func;
userData->user_data = user_data;
thumb_dbg_slog("Path : %s", origin_path);
thumbRawUserData *userData = (thumbRawUserData*)malloc(sizeof(thumbRawUserData));
+ if(userData == NULL) {
+ thumb_err("userData malloc failed : %d", err);
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
+ }
userData->func = func;
userData->user_data = user_data;
#include <glib.h>
#include <string.h>
#include <unistd.h>
-#include <util-func.h>
static __thread MediaDBHandle *db_handle;
-static int _media_thumb_busy_handler(void *pData, int count)
-{
- usleep(50000);
- thumb_dbg("_media_thumb_busy_handler called : %d\n", count);
-
- return 100 - count;
-}
-
sqlite3 *_media_thumb_db_get_handle()
{
return db_handle;
}
-int _media_thumb_sqlite_connect(sqlite3 **handle)
-{
- int err = MS_MEDIA_ERR_NONE;
-
- err = db_util_open(MEDIA_DATABASE_NAME, handle,
- DB_UTIL_REGISTER_HOOK_METHOD);
-
- if (SQLITE_OK != err) {
- *handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- /*Register busy handler*/
- if (*handle) {
- err = sqlite3_busy_handler(*handle, _media_thumb_busy_handler, NULL);
- if (SQLITE_OK != err) {
- if (*handle) {
- thumb_err("[sqlite] %s\n", sqlite3_errmsg(*handle));
- db_util_close(*handle);
- }
- *handle = NULL;
-
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- } else {
- *handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int _media_thumb_sqlite_disconnect(sqlite3 *handle)
-{
- int err = MS_MEDIA_ERR_NONE;
- if (handle != NULL) {
- err = db_util_close(handle);
-
- if (SQLITE_OK != err) {
- handle = NULL;
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int
-_media_thumb_get_type_from_db(sqlite3 *handle,
+int _media_thumb_get_type_from_db(sqlite3 *handle,
const char *origin_path,
int *type)
{
+ int err = MS_MEDIA_ERR_NONE;
+ char *path_string = NULL;
+ char *query_string = NULL;
+ sqlite3_stmt *stmt = NULL;
+
thumb_dbg_slog("Origin path : %s", origin_path);
if (handle == NULL) {
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- int err = -1;
- char *path_string = NULL;
- char *query_string = NULL;
- sqlite3_stmt *stmt = NULL;
-
path_string = sqlite3_mprintf("%s", origin_path);
query_string = sqlite3_mprintf(SELECT_TYPE_BY_PATH, path_string);