diff --git a/configure.ac b/configure.ac index 3f28097..16d9233 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ m4_define([version_major], [0]) -m4_define([version_minor], [7]) +m4_define([version_minor], [8]) m4_define([version_micro], [0]) m4_define([version_micro_extra], version_micro) m4_append([version_micro_extra], []) @@ -156,6 +156,16 @@ AC_MSG_RESULT([$enable_test_apps]) AC_DEFINE(FUSE_USE_VERSION, 26, [Fuse API Version]) +# check if we should enable strict compile warnings +AC_ARG_ENABLE(strict-compile, + AS_HELP_STRING(--enable-strict-compile, enable support for strict compiler warnings), + [], [enable_strict_compile=no] +) + +if test "x$enable_strict_compile" = "xyes" ; then + CFLAGS="$CFLAGS -Wextra -pedantic -Wall" +fi + # check if we should enable verbose debugging AC_ARG_ENABLE(debug, AS_HELP_STRING(--enable-debug, enable support for running in debug mode), diff --git a/include/cache_mng.h b/include/cache_mng.h index cd0deb7..bdbfc9b 100644 --- a/include/cache_mng.h +++ b/include/cache_mng.h @@ -44,14 +44,9 @@ guint64 cache_mng_size (CacheMng *cmng); // return total size of cached file guint64 cache_mng_get_file_length (CacheMng *cmng, fuse_ino_t ino); -// return MD5 of cached file. -// if result is TRUE then md5str will containd string with MD5 sum -gboolean cache_mng_get_md5 (CacheMng *cmng, fuse_ino_t ino, gchar **md5str); - -// return version ID of cached file -// return NULL if version ID is not set -const gchar *cache_mng_get_version_id (CacheMng *cmng, fuse_ino_t ino); -void cache_mng_update_version_id (CacheMng *cmng, fuse_ino_t ino, const gchar *version_id); +// return and update local copy of AWS ETag for this file +const char *cache_mng_get_etag(CacheMng *cmng, fuse_ino_t ino); +gboolean cache_mng_update_etag(CacheMng *cmng, fuse_ino_t ino, const char *etag); void cache_mng_get_stats (CacheMng *cmng, guint32 *entries_num, guint64 *total_size, guint64 *cache_hits, guint64 *cache_miss); #endif diff --git a/include/conf_keys.h b/include/conf_keys.h index d08536d..4336855 100644 --- a/include/conf_keys.h +++ b/include/conf_keys.h @@ -40,10 +40,8 @@ const gchar *conf_keys_str[] = { "connection.max_retries", "filesystem.dir_cache_max_time", "filesystem.file_cache_max_time", - "filesystem.md5_enabled", "filesystem.cache_enabled", "filesystem.cache_dir", - "filesystem.cache_dir_max_size", "filesystem.cache_object_ttl", "filesystem.uid", "filesystem.gid", diff --git a/include/dir_tree.h b/include/dir_tree.h index 8f7c580..c2521ce 100644 --- a/include/dir_tree.h +++ b/include/dir_tree.h @@ -33,8 +33,6 @@ void dir_tree_destroy (DirTree *dtree); DirEntry *dir_tree_update_entry (DirTree *dtree, const gchar *path, DirEntryType type, fuse_ino_t parent_ino, const gchar *entry_name, long long size, time_t last_modified); -void dir_tree_entry_update_xattrs (DirEntry *en, struct evkeyvalq *headers); - // mark that DirTree is being updated void dir_tree_start_update (DirEntry *en, G_GNUC_UNUSED const gchar *dir_path); diff --git a/include/global.h b/include/global.h index 4ee62e4..5598872 100644 --- a/include/global.h +++ b/include/global.h @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include diff --git a/include/http_connection.h b/include/http_connection.h index 2f73720..edfa15a 100644 --- a/include/http_connection.h +++ b/include/http_connection.h @@ -81,14 +81,14 @@ typedef void (*HttpConnection_on_entry_sent_cb) (gpointer ctx, gboolean success) void http_connection_file_send (HttpConnection *con, int fd, const gchar *resource_path, HttpConnection_on_entry_sent_cb on_entry_sent_cb, gpointer ctx); -typedef void (*HttpConnection_responce_cb) (HttpConnection *con, gpointer ctx, gboolean success, +typedef void (*HttpConnection_response_cb) (HttpConnection *con, gpointer ctx, gboolean success, const gchar *buf, size_t buf_len, struct evkeyvalq *headers); gboolean http_connection_make_request (HttpConnection *con, const gchar *resource_path, const gchar *http_cmd, struct evbuffer *out_buffer, gboolean enable_retry, gpointer parent_request_data, - HttpConnection_responce_cb responce_cb, + HttpConnection_response_cb response_cb, gpointer ctx); #endif diff --git a/include/log.h b/include/log.h index aa405bb..f8b752f 100644 --- a/include/log.h +++ b/include/log.h @@ -35,6 +35,9 @@ void logger_set_color (gboolean use); void logger_set_file (FILE *f); void logger_destroy (void); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wvariadic-macros" + #define LOG_debug(subsystem, x...) \ G_STMT_START { \ logger_log_msg (__FILE__, __LINE__, __func__, LOG_debug, subsystem, x); \ @@ -50,4 +53,6 @@ G_STMT_START { \ logger_log_msg (__FILE__, __LINE__, __func__, LOG_err, subsystem, x); \ } G_STMT_END +#pragma GCC diagnostic pop + #endif diff --git a/riofs.conf.xml b/riofs.conf.xml index 53994c7..b6d9e39 100644 --- a/riofs.conf.xml +++ b/riofs.conf.xml @@ -80,17 +80,18 @@ 10 - - True - True /tmp/riofs - + + 1073741824 + + 600 diff --git a/src/cache_mng.c b/src/cache_mng.c index e7e1c3b..1a94b45 100644 --- a/src/cache_mng.c +++ b/src/cache_mng.c @@ -41,7 +41,7 @@ struct _CacheEntry { Range *avail_range; time_t modification_time; GList *ll_lru; - gchar *version_id; + gchar *etag; }; struct _CacheContext { @@ -74,7 +74,14 @@ CacheMng *cache_mng_create (Application *app) cmng->q_lru = g_queue_new (); cmng->size = 0; cmng->check_time = time (NULL); - cmng->max_size = conf_get_uint (application_get_conf (cmng->app), "filesystem.cache_dir_max_size"); + // If "filesystem.cache_dir_max_megabyte_size" is set, use it, else use "filesystem.cache_dir_max_size" + if (conf_node_exists (application_get_conf (cmng->app), "filesystem.cache_dir_max_megabyte_size")) { + cmng->max_size = conf_get_uint (application_get_conf (cmng->app), "filesystem.cache_dir_max_megabyte_size"); + cmng->max_size *= 1024 * 1024; // Convert from megabytes to bytes + } else { + cmng->max_size = conf_get_uint (application_get_conf (cmng->app), "filesystem.cache_dir_max_size"); + } + LOG_debug (CMNG_LOG, "Maximum cache size (bytes): %"PRId64, cmng->max_size); // generate random folder name for storing cache rnd_str = get_random_string (20, TRUE); cmng->cache_dir = g_strdup_printf ("%s/%s", @@ -110,7 +117,7 @@ static struct _CacheEntry* cache_entry_create (fuse_ino_t ino) entry->avail_range = range_create (); entry->ll_lru = NULL; entry->modification_time = time (NULL); - entry->version_id = NULL; // version not set + entry->etag = NULL; return entry; } @@ -120,8 +127,8 @@ static void cache_entry_destroy (gpointer data) struct _CacheEntry * entry = (struct _CacheEntry*) data; range_destroy(entry->avail_range); - if (entry->version_id) - g_free (entry->version_id); + if (entry->etag) + g_free (entry->etag); g_free(entry); } @@ -179,55 +186,8 @@ static void cache_mng_rm_cache_dir (CacheMng *cmng) } } - -// we can only get md5 of an object containing 1 range -// XXX: move code to separate thread -gboolean cache_mng_get_md5 (CacheMng *cmng, fuse_ino_t ino, gchar **md5str) -{ - struct _CacheEntry *entry; - unsigned char digest[MD5_DIGEST_LENGTH]; - MD5_CTX md5ctx; - ssize_t bytes; - unsigned char data[1024]; - char path[PATH_MAX]; - size_t i; - gchar *out; - FILE *in; - - entry = g_hash_table_lookup (cmng->h_entries, GUINT_TO_POINTER (ino)); - if (!entry) - return FALSE; - - if (range_count (entry->avail_range) != 1) { - LOG_debug (CMNG_LOG, INO_H"Entry contains more than 1 range, can't take MD5 sum of such object !", INO_T (ino)); - return FALSE; - } - - cache_mng_file_name (cmng, path, sizeof (path), ino); - in = fopen (path, "rb"); - if (in == NULL) { - LOG_debug (CMNG_LOG, INO_H"Can't open file for reading: %s", INO_T (ino), path); - return FALSE; - } - - MD5_Init (&md5ctx); - while ((bytes = fread (data, 1, 1024, in)) != 0) - MD5_Update (&md5ctx, data, bytes); - MD5_Final (digest, &md5ctx); - fclose (in); - - out = g_malloc (33); - for (i = 0; i < 16; ++i) - sprintf (&out[i*2], "%02x", (unsigned int)digest[i]); - - *md5str = out; - - return TRUE; -} - -// return version ID of cached file -// return NULL if version ID is not set -const gchar *cache_mng_get_version_id (CacheMng *cmng, fuse_ino_t ino) +// What was Amazon's AWS ETag for this inode, when we cached it? +const gchar *cache_mng_get_etag (CacheMng *cmng, fuse_ino_t ino) { struct _CacheEntry *entry; @@ -235,24 +195,26 @@ const gchar *cache_mng_get_version_id (CacheMng *cmng, fuse_ino_t ino) if (!entry) return NULL; - return entry->version_id; + return entry->etag; } -void cache_mng_update_version_id (CacheMng *cmng, fuse_ino_t ino, const gchar *version_id) +gboolean cache_mng_update_etag (CacheMng *cmng, fuse_ino_t ino, const gchar *etag) { struct _CacheEntry *entry; entry = g_hash_table_lookup (cmng->h_entries, GUINT_TO_POINTER (ino)); if (!entry) - return; + return FALSE; - if (entry->version_id) { - if (strcmp (entry->version_id, version_id)) { - g_free (entry->version_id); - entry->version_id = g_strdup (version_id); + if (entry->etag) { + if (strcmp (entry->etag, etag)) { + g_free (entry->etag); + entry->etag = g_strdup (etag); } } else - entry->version_id = g_strdup (version_id); + entry->etag = g_strdup (etag); + + return TRUE; } /*}}}*/ diff --git a/src/conf.c b/src/conf.c index f48f499..b4ffbf3 100644 --- a/src/conf.c +++ b/src/conf.c @@ -199,6 +199,7 @@ static void text_handler (G_GNUC_UNUSED GMarkupParseContext *context, const gcha } } else if (conf_node->type == CT_LIST) { l = NULL; + saved = NULL; // workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71701 // split string and remove whitespaces for (tok = strtok_r (tmp_text, ",", &saved); tok; tok = strtok_r (NULL, ",", &saved)) { tok_striped = g_strstrip (tok); diff --git a/src/dir_tree.c b/src/dir_tree.c index 612788d..74388ff 100644 --- a/src/dir_tree.c +++ b/src/dir_tree.c @@ -23,6 +23,35 @@ #include "cache_mng.h" #include "utils.h" +/* + * The following union and convert_*() routines + * convert between a pointer (that might be either + * 32 or 64 bits, depending on architecture), and + * a 64 bit integer (the fuse fh, always uint64_t), + * and they do this without generating warnings + * when compiling with strict options. + */ +typedef union { + uint64_t fh; + void *p; +} u64_ptr_union_t; + +static uint64_t convert_ptr_to_fh (void *p) +{ + u64_ptr_union_t u64_ptr_u; + + u64_ptr_u.p = p; + return u64_ptr_u.fh; +} + +static void *convert_fh_to_ptr (uint64_t fh) +{ + u64_ptr_union_t u64_ptr_u; + + u64_ptr_u.fh = fh; + return u64_ptr_u.p; +} + /*{{{ struct / defines*/ struct _DirEntry { @@ -85,6 +114,7 @@ static DirEntry *dir_tree_add_entry (DirTree *dtree, const gchar *basename, mode DirEntryType type, fuse_ino_t parent_ino, off_t size, time_t ctime); static void dir_tree_entry_modified (DirTree *dtree, DirEntry *en); static void dir_entry_destroy (gpointer data); +static void dir_tree_entry_update_xattrs (DirEntry *en, struct evkeyvalq *headers); /*}}}*/ /*{{{ create / destroy */ @@ -439,7 +469,7 @@ void dir_tree_fill_on_dir_buf_cb (gpointer callback_data, gboolean success) } LOG_debug (DIR_TREE_LOG, "[ino: %"INO_FMT" req: %p] Dir fill callback: %s", - INO_T (dir_fill_data->ino), dir_fill_data->req, success ? "SUCCESS" : "FAILED"); + INO_T (dir_fill_data->ino), (void *)dir_fill_data->req, success ? "SUCCESS" : "FAILED"); en->dir_cache_updating = FALSE; // directory is updated @@ -568,7 +598,7 @@ gboolean dir_tree_opendir (DirTree *dtree, fuse_ino_t ino, struct fuse_file_info dop->buf = NULL; dop->size = 0; - fi->fh = (uint64_t) dop; + fi->fh = convert_ptr_to_fh (dop); return TRUE; } @@ -577,7 +607,7 @@ gboolean dir_tree_releasedir (G_GNUC_UNUSED DirTree *dtree, G_GNUC_UNUSED fuse_i { DirOpData *dop; - dop = (DirOpData *) fi->fh; + dop = convert_fh_to_ptr (fi->fh); if (dop) { if (dop->buf) g_free (dop->buf); @@ -612,7 +642,7 @@ void dir_tree_fill_dir_buf (DirTree *dtree, // get request structure if (fi && fi->fh) { - dop = (DirOpData *) fi->fh; + dop = convert_fh_to_ptr (fi->fh); } // if request buffer is set - return it right away @@ -1304,9 +1334,9 @@ void dir_tree_file_create (DirTree *dtree, fuse_ino_t parent_ino, const char *na en->is_modified = TRUE; fop = fileio_create (dtree->app, en->fullpath, en->ino, TRUE); - fi->fh = (uint64_t) fop; + fi->fh = convert_ptr_to_fh (fop); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"New Entry created: %s, directory ino: %"INO_FMT, INO_T (en->ino), fop, name, INO parent_ino); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"New Entry created: %s, directory ino: %"INO_FMT, INO_T (en->ino), (void *)fop, name, INO parent_ino); file_create_cb (req, TRUE, en->ino, en->mode, en->size, fi); } @@ -1331,9 +1361,9 @@ void dir_tree_file_open (DirTree *dtree, fuse_ino_t ino, struct fuse_file_info * } fop = fileio_create (dtree->app, en->fullpath, en->ino, FALSE); - fi->fh = (uint64_t) fop; + fi->fh = convert_ptr_to_fh (fop); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"dir_tree_open", INO_T (en->ino), fop); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"dir_tree_open", INO_T (en->ino), (void *)fop); file_open_cb (req, TRUE, fi); } @@ -1356,9 +1386,9 @@ void dir_tree_file_release (DirTree *dtree, fuse_ino_t ino, G_GNUC_UNUSED struct return; } - fop = (FileIO *)fi->fh; + fop = convert_fh_to_ptr (fi->fh); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"dir_tree_file_release", INO_T (ino), fop); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"dir_tree_file_release", INO_T (ino), (void *)fop); fileio_release (fop); } @@ -1377,10 +1407,10 @@ static void dir_tree_on_buffer_read_cb (gpointer ctx, gboolean success, char *bu { FileReadOpData *op_data = (FileReadOpData *)ctx; - LOG_debug (DIR_TREE_LOG, INO_FROP_H"file READ_cb !", INO_T (op_data->ino), op_data); + LOG_debug (DIR_TREE_LOG, INO_FROP_H"file READ_cb !", INO_T (op_data->ino), (void *)op_data); if (!success) { - LOG_err (DIR_TREE_LOG, INO_FROP_H"Failed to read file !", INO_T (op_data->ino), op_data); + LOG_err (DIR_TREE_LOG, INO_FROP_H"Failed to read file !", INO_T (op_data->ino), (void *)op_data); op_data->file_read_cb (op_data->req, FALSE, NULL, 0); g_free (op_data); return; @@ -1410,9 +1440,9 @@ void dir_tree_file_read (DirTree *dtree, fuse_ino_t ino, return; } - fop = (FileIO *)fi->fh; + fop = convert_fh_to_ptr (fi->fh); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"Read inode, size: %zu, off: %"OFF_FMT, INO_T (ino), fop, size, off); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"Read inode, size: %zu, off: %"OFF_FMT, INO_T (ino), (void *)fop, size, off); op_data = g_new0 (FileReadOpData, 1); op_data->file_read_cb = file_read_cb; @@ -1442,7 +1472,7 @@ static void dir_tree_on_buffer_written_cb (FileIO *fop, gpointer ctx, gboolean s op_data->file_write_cb (op_data->req, success, count); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"Buffer written, count: %zu", INO_T (op_data->ino), fop, count); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"Buffer written, count: %zu", INO_T (op_data->ino), (void *)fop, count); // we need to update entry size ! if (success) { @@ -1491,12 +1521,12 @@ void dir_tree_file_write (DirTree *dtree, fuse_ino_t ino, return; } - fop = (FileIO *)fi->fh; + fop = convert_fh_to_ptr (fi->fh); // set updated time for write op en->updated_time = time (NULL); - LOG_debug (DIR_TREE_LOG, INO_FOP_H"write inode, size: %zu, off: %"OFF_FMT, INO_T (ino), fop, size, off); + LOG_debug (DIR_TREE_LOG, INO_FOP_H"write inode, size: %zu, off: %"OFF_FMT, INO_T (ino), (void *)fop, size, off); op_data = g_new0 (FileWriteOpData, 1); op_data->dtree = dtree; @@ -1533,7 +1563,7 @@ static void dir_tree_file_remove_on_con_data_cb (HttpConnection *con, gpointer c LOG_err (DIR_TREE_LOG, INO_H"Entry not found !", INO_T (data->ino)); if (data->file_remove_cb) data->file_remove_cb (data->req, FALSE); - g_free (data); + g_free (data); return; } @@ -2005,7 +2035,7 @@ static void dir_tree_on_rename_copy_con_cb (gpointer client, gpointer ctx) else dst_path = g_strdup_printf ("/%s/%s", newparent_en->fullpath, rdata->newname); - LOG_debug (DIR_TREE_LOG, INO_CON_H"Rename: coping %s to %s", INO_T (en->ino), con, en->fullpath, dst_path); + LOG_debug (DIR_TREE_LOG, INO_CON_H"Rename: coping %s to %s", INO_T (en->ino), (void *)con, en->fullpath, dst_path); res = http_connection_make_request (con, dst_path, "PUT", @@ -2131,7 +2161,7 @@ static const gchar *dir_tree_getxattr_from_entry (DirEntry *en, XAttrType attr_t return out; } -void dir_tree_entry_update_xattrs (DirEntry *en, struct evkeyvalq *headers) +static void dir_tree_entry_update_xattrs (DirEntry *en, struct evkeyvalq *headers) { const gchar *header = NULL; diff --git a/src/file_io_ops.c b/src/file_io_ops.c index 6e87f25..d16954c 100644 --- a/src/file_io_ops.c +++ b/src/file_io_ops.c @@ -99,89 +99,10 @@ void fileio_destroy (FileIO *fop) /*{{{ fileio_release*/ -/*{{{ update headers on uploaded object */ -static void fileio_release_on_update_header_cb (HttpConnection *con, void *ctx, gboolean success, - G_GNUC_UNUSED const gchar *buf, G_GNUC_UNUSED size_t buf_len, - G_GNUC_UNUSED struct evkeyvalq *headers) -{ - FileIO *fop = (FileIO *) ctx; - - http_connection_release (con); - - if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to update headers on the server !", INO_T (fop->ino), con); - fileio_destroy (fop); - return; - } - - // done - LOG_debug (FIO_LOG, INO_CON_H"Headers are updated !", INO_T (fop->ino), con); - - fileio_destroy (fop); -} - -// got HttpConnection object -static void fileio_release_on_update_headers_con_cb (gpointer client, gpointer ctx) -{ - HttpConnection *con = (HttpConnection *) client; - FileIO *fop = (FileIO *) ctx; - gchar *path; - gchar *cpy_path; - gboolean res; - unsigned char digest[16]; - gchar *md5str; - size_t i; - - LOG_debug (FIO_LOG, INO_CON_H"Updating object's headers..", INO_T (fop->ino), con); - - http_connection_acquire (con); - - if (fop->content_type) - http_connection_add_output_header (con, "Content-Type", fop->content_type); - http_connection_add_output_header (con, "x-amz-metadata-directive", "REPLACE"); - http_connection_add_output_header (con, "x-amz-storage-class", conf_get_string (application_get_conf (con->app), "s3.storage_type")); - - MD5_Final (digest, &fop->md5); - md5str = g_malloc (33); - for (i = 0; i < 16; ++i) - sprintf(&md5str[i*2], "%02x", (unsigned int)digest[i]); - http_connection_add_output_header (con, "x-amz-meta-md5", md5str); - g_free (md5str); - - cpy_path = g_strdup_printf ("%s%s", conf_get_string (application_get_conf (fop->app), "s3.bucket_name"), fop->fname); - http_connection_add_output_header (con, "x-amz-copy-source", cpy_path); - g_free (cpy_path); - - path = g_strdup_printf ("%s", fop->fname); - res = http_connection_make_request (con, - path, "PUT", NULL, TRUE, NULL, - fileio_release_on_update_header_cb, - fop - ); - g_free (path); - - if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (fop->ino), con); - http_connection_release (con); - fileio_destroy (fop); - return; - } -} - static void fileio_release_update_headers (FileIO *fop) { - // update MD5 headers only if versioning is disabled - if (conf_get_boolean (application_get_conf (fop->app), "s3.versioning")) { LOG_debug (FIO_LOG, INO_H"File uploaded !", INO_T (fop->ino)); fileio_destroy (fop); - } else { - if (!client_pool_get_client (application_get_write_client_pool (fop->app), - fileio_release_on_update_headers_con_cb, fop)) { - LOG_err (FIO_LOG, INO_H"Failed to get HTTP client !", INO_T (fop->ino)); - fileio_destroy (fop); - return; - } - } } /*}}}*/ @@ -192,24 +113,17 @@ static void fileio_release_on_complete_cb (HttpConnection *con, void *ctx, gbool G_GNUC_UNUSED struct evkeyvalq *headers) { FileIO *fop = (FileIO *) ctx; - const gchar *versioning_header; http_connection_release (con); if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to send Multipart data to the server !", INO_T (fop->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to send Multipart data to the server !", INO_T (fop->ino), (void *)con); fileio_destroy (fop); return; } - versioning_header = http_find_header (headers, "x-amz-version-id"); - if (versioning_header) { - cache_mng_update_version_id (application_get_cache_mng (fop->app), - fop->ino, versioning_header); - } - // done - LOG_debug (FIO_LOG, INO_CON_H"Multipart Upload is done !", INO_T (fop->ino), con); + LOG_debug (FIO_LOG, INO_CON_H"Multipart Upload is done !", INO_T (fop->ino), (void *)con); // fileio_destroy (fop); fileio_release_update_headers (fop); @@ -235,7 +149,7 @@ static void fileio_release_on_complete_con_cb (gpointer client, gpointer ctx) } evbuffer_add_printf (xml_buf, "%s", ""); - LOG_debug (FIO_LOG, INO_CON_H"Sending Multipart Final part..", INO_T (fop->ino), con); + LOG_debug (FIO_LOG, INO_CON_H"Sending Multipart Final part..", INO_T (fop->ino), (void *)con); http_connection_acquire (con); @@ -250,7 +164,7 @@ static void fileio_release_on_complete_con_cb (gpointer client, gpointer ctx) evbuffer_free (xml_buf); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (fop->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (fop->ino), (void *)con); http_connection_release (con); fileio_destroy (fop); return; @@ -281,21 +195,15 @@ static void fileio_release_on_part_sent_cb (HttpConnection *con, void *ctx, gboo G_GNUC_UNUSED struct evkeyvalq *headers) { FileIO *fop = (FileIO *) ctx; - const gchar *versioning_header; http_connection_release (con); if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to send bufer to server !", INO_T (fop->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to send buffer to server !", INO_T (fop->ino), (void *)con); fileio_destroy (fop); return; } - versioning_header = http_find_header (headers, "x-amz-version-id"); - if (versioning_header) { - cache_mng_update_version_id (application_get_cache_mng (fop->app), - fop->ino, versioning_header); - } // if it's a multi part upload - Complete Multipart Upload if (fop->multipart_initiated) { fileio_release_complete_multipart (fop); @@ -318,7 +226,7 @@ static void fileio_release_on_part_con_cb (gpointer client, gpointer ctx) size_t buf_len; const gchar *buf; - LOG_debug (FIO_LOG, INO_CON_H"Releasing fop. Size: %zu", INO_T (fop->ino), con, evbuffer_get_length (fop->write_buf)); + LOG_debug (FIO_LOG, INO_CON_H"Releasing fop. Size: %zu", INO_T (fop->ino), (void *)con, evbuffer_get_length (fop->write_buf)); // add part information to the list part = g_new0 (FileIOPart, 1); @@ -338,7 +246,7 @@ static void fileio_release_on_part_con_cb (gpointer client, gpointer ctx) if (fop->multipart_initiated) { if (!fop->uploadid) { - LOG_err (FIO_LOG, INO_CON_H"UploadID is not set, aborting operation !", INO_T (fop->ino), con); + LOG_err (FIO_LOG, INO_CON_H"UploadID is not set, aborting operation !", INO_T (fop->ino), (void *)con); fileio_destroy (fop); return; } @@ -392,7 +300,7 @@ static void fileio_release_on_part_con_cb (gpointer client, gpointer ctx) g_free (path); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (fop->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (fop->ino), (void *)con); http_connection_release (con); fileio_destroy (fop); return; @@ -443,23 +351,16 @@ static void fileio_write_on_send_cb (HttpConnection *con, void *ctx, gboolean su G_GNUC_UNUSED struct evkeyvalq *headers) { FileWriteData *wdata = (FileWriteData *) ctx; - const char *versioning_header; http_connection_release (con); if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to send bufer to server !", INO_T (wdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to send buffer to server !", INO_T (wdata->ino), (void *)con); wdata->on_buffer_written_cb (wdata->fop, wdata->ctx, FALSE, 0); g_free (wdata); return; } - versioning_header = http_find_header (headers, "x-amz-version-id"); - if (versioning_header) { - cache_mng_update_version_id (application_get_cache_mng (wdata->fop->app), - wdata->ino, versioning_header); - } - // empty part buffer evbuffer_drain (wdata->fop->write_buf, -1); @@ -513,7 +414,7 @@ static void fileio_write_on_send_con_cb (gpointer client, gpointer ctx) g_free (path); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (wdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (wdata->ino), (void *)con); http_connection_release (con); wdata->on_buffer_written_cb (wdata->fop, wdata->ctx, FALSE, 0); g_free (wdata); @@ -595,7 +496,7 @@ static void fileio_write_on_multipart_init_cb (HttpConnection *con, void *ctx, g wdata->fop->multipart_initiated = TRUE; if (!success || !buf_len) { - LOG_err (FIO_LOG, INO_CON_H"Failed to get multipart init data from the server !", INO_T (wdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to get multipart init data from the server !", INO_T (wdata->ino), (void *)con); wdata->on_buffer_written_cb (wdata->fop, wdata->ctx, FALSE, 0); g_free (wdata); return; @@ -603,7 +504,7 @@ static void fileio_write_on_multipart_init_cb (HttpConnection *con, void *ctx, g uploadid = get_uploadid (buf, buf_len); if (!uploadid) { - LOG_err (FIO_LOG, INO_CON_H"Failed to parse multipart init data!", INO_T (wdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to parse multipart init data!", INO_T (wdata->ino), (void *)con); wdata->on_buffer_written_cb (wdata->fop, wdata->ctx, FALSE, 0); g_free (wdata); return; @@ -639,7 +540,7 @@ static void fileio_write_on_multipart_init_con_cb (gpointer client, gpointer ctx g_free (path); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (wdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (wdata->ino), (void *)con); http_connection_release (con); wdata->on_buffer_written_cb (wdata->fop, wdata->ctx, FALSE, 0); g_free (wdata); @@ -721,37 +622,95 @@ typedef struct { off_t request_offset; FileIO_on_buffer_read_cb on_buffer_read_cb; gpointer ctx; + char *aws_etag; + gboolean cache_etag_is_set; } FileReadData; +void fileread_destroy (FileReadData *rdata) +{ + if (rdata->aws_etag) + g_free (rdata->aws_etag); + g_free (rdata); +} + static void fileio_read_get_buf (FileReadData *rdata); +static gboolean insure_cache_etag_consistent_or_invalidate_cache(struct evkeyvalq *headers, FileReadData *rdata) +{ + const char *aws_etag, *cached_etag; + + // consistency checking: + // If AWS and cached ETag's aren't equal, invalidate local cache + + aws_etag = http_find_header (headers, "ETag"); + + if (!aws_etag) { + LOG_err (FIO_LOG, INO_H"Header fails to contain ETag!", INO_T (rdata->ino)); + rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); + fileread_destroy (rdata); + return FALSE; + } + + if (!rdata->aws_etag) + rdata->aws_etag = strdup (aws_etag); + else if (strcmp (rdata->aws_etag, aws_etag)) { + g_free (rdata->aws_etag); + rdata->aws_etag = strdup (aws_etag); + } + + cached_etag = cache_mng_get_etag (application_get_cache_mng (rdata->fop->app), rdata->ino); + + if (cached_etag) { + if (!strcmp(rdata->aws_etag, cached_etag)) { + LOG_debug (FIO_LOG, INO_H"ETags same %.8s..., using local cached file", + INO_T (rdata->ino), rdata->aws_etag+1); + } else { + LOG_debug (FIO_LOG, INO_H"ETags differ, invalidating local cached file!: AWS %.8s..., cache %.8s...", + INO_T (rdata->ino), rdata->aws_etag+1, cached_etag+1); + cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); + } + } else { + if (cache_mng_update_etag (application_get_cache_mng (rdata->fop->app), rdata->ino, rdata->aws_etag)) { + LOG_debug (FIO_LOG, INO_H"Set cache etag: %.8s...", INO_T (rdata->ino), rdata->aws_etag+1); + rdata->cache_etag_is_set = TRUE; + } + } + + return TRUE; +} + /*{{{ GET request */ static void fileio_read_on_get_cb (HttpConnection *con, void *ctx, gboolean success, - const gchar *buf, size_t buf_len, - G_GNUC_UNUSED struct evkeyvalq *headers) + const gchar *buf, size_t buf_len, struct evkeyvalq *headers) { FileReadData *rdata = (FileReadData *) ctx; - const char *versioning_header = NULL; + const char *cached_etag; // release HttpConnection http_connection_release (con); if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to get file from server !", INO_T (rdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to get file from server !", INO_T (rdata->ino), (void *)con); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); return; } + if (!insure_cache_etag_consistent_or_invalidate_cache(headers, rdata)) + return; + // store it in the local cache cache_mng_store_file_buf (application_get_cache_mng (rdata->fop->app), rdata->ino, buf_len, rdata->request_offset, (unsigned char *) buf, NULL, NULL); - // update version ID - versioning_header = http_find_header (headers, "x-amz-version-id"); - if (versioning_header) { - cache_mng_update_version_id (application_get_cache_mng (rdata->fop->app), rdata->ino, versioning_header); + cached_etag = cache_mng_get_etag (application_get_cache_mng (rdata->fop->app), rdata->ino); + LOG_debug (FIO_LOG, INO_H"Read from server done, AWS etag %.8s..., cache etag %.8s...", + INO_T (rdata->ino), rdata->aws_etag+1, cached_etag ? cached_etag+1 : "not set"); + + if (rdata->aws_etag && !cached_etag) { + LOG_debug (FIO_LOG, INO_H"Setting cache etag: %.8s...", INO_T (rdata->ino), rdata->aws_etag+1); + cache_mng_update_etag (application_get_cache_mng (rdata->fop->app), rdata->ino, rdata->aws_etag); } LOG_debug (FIO_LOG, INO_H"Storing [%"G_GUINT64_FORMAT" %zu]", INO_T(rdata->ino), rdata->request_offset, buf_len); @@ -797,10 +756,10 @@ static void fileio_read_on_con_cb (gpointer client, gpointer ctx) ); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (rdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (rdata->ino), (void *)con); http_connection_release (con); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); return; } } @@ -809,17 +768,21 @@ static void fileio_read_on_cache_cb (unsigned char *buf, size_t size, gboolean s { FileReadData *rdata = (FileReadData *) ctx; - // we got data from the cache if (success) { + // read directly from cache LOG_debug (FIO_LOG, INO_H"Reading from cache", INO_T (rdata->ino)); rdata->on_buffer_read_cb (rdata->ctx, TRUE, (char *)buf, size); - g_free (rdata); + fileread_destroy (rdata); } else { + // try reading from server, using fileio_read_on_con_cb() callback LOG_debug (FIO_LOG, INO_H"Reading from server !", INO_T (rdata->ino)); - if (!client_pool_get_client (application_get_read_client_pool (rdata->fop->app), fileio_read_on_con_cb, rdata)) { + if (client_pool_get_client (application_get_read_client_pool (rdata->fop->app), fileio_read_on_con_cb, rdata)) { + // fileio_read_on_con_cb() callback will resume handling this request + } else { + // couldn't get HTTP client to try accessing server; fail directly LOG_err (FIO_LOG, INO_H"Failed to get HTTP client !", INO_T (rdata->ino)); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); return; } } @@ -874,91 +837,36 @@ static void fileio_read_on_head_cb (HttpConnection *con, void *ctx, gboolean suc http_connection_release (con); if (!success) { - LOG_err (FIO_LOG, INO_CON_H"Failed to get HEAD from server !", INO_T (rdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to get HEAD from server !", INO_T (rdata->ino), (void *)con); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); return; } rdata->fop->head_req_sent = TRUE; + // update DirTree dtree = application_get_dir_tree (rdata->fop->app); dir_tree_set_entry_exist (dtree, rdata->ino); - // consistency checking: - - // 1. check local and remote file sizes + // Set file size from header Content-Length content_len_header = http_find_header (headers, "Content-Length"); if (content_len_header) { - guint64 local_size = 0; gint64 size = 0; size = strtoll ((char *)content_len_header, NULL, 10); if (size < 0) { - LOG_err (FIO_LOG, INO_CON_H"Header contains incorrect file size!", INO_T (rdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Header contains incorrect file size!", INO_T (rdata->ino), (void *)con); size = 0; } rdata->fop->file_size = size; LOG_debug (FIO_LOG, INO_H"Remote file size: %"G_GUINT64_FORMAT, INO_T (rdata->ino), rdata->fop->file_size); - - local_size = cache_mng_get_file_length (application_get_cache_mng (rdata->fop->app), rdata->ino); - if (local_size != rdata->fop->file_size) { - LOG_debug (FIO_LOG, INO_H"Local and remote file sizes do not match, invalidating local cached file!", - INO_T (rdata->ino)); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } } - // 2. use one of the following ways to check that local and remote files are identical - // if versioning is enabled: compare version IDs - // if bucket has versioning disabled: compare MD5 sums - if (conf_get_boolean (application_get_conf (rdata->fop->app), "s3.versioning")) { - const char *versioning_header = http_find_header (headers, "x-amz-version-id"); - if (versioning_header) { - const gchar *local_version_id = cache_mng_get_version_id (application_get_cache_mng (rdata->fop->app), rdata->ino); - if (local_version_id && !strcmp (local_version_id, versioning_header)) { - LOG_debug (FIO_LOG, INO_H"Both version IDs match, using local cached file!", INO_T (rdata->ino)); - } else { - LOG_debug (FIO_LOG, INO_H"Version IDs do not match, invalidating local cached file!: %s %s", - INO_T (rdata->ino), local_version_id, versioning_header); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } - - // header was not found - } else { - LOG_debug (FIO_LOG, INO_H"Versioning header was not found, invalidating local cached file!", INO_T (rdata->ino)); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } - - //check for MD5 - } else { - const char *md5_header = http_find_header (headers, "x-amz-meta-md5"); - if (md5_header) { - gchar *md5str = NULL; - - // at this point we have both remote and local MD5 sums - if (cache_mng_get_md5 (application_get_cache_mng (rdata->fop->app), rdata->ino, &md5str)) { - if (!strncmp (md5_header, md5str, 32)) { - LOG_debug (FIO_LOG, INO_H"MD5 sums match, using local cached file!", INO_T (rdata->ino)); - } else { - LOG_debug (FIO_LOG, INO_H"MD5 sums do not match, invalidating local cached file!", INO_T (rdata->ino)); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } - } else { - LOG_debug (FIO_LOG, INO_H"Failed to get local MD5 sum, invalidating local cached file!", INO_T (rdata->ino)); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } - - if (md5str) - g_free (md5str); - - // header was not found - } else { - LOG_debug (FIO_LOG, INO_H"MD5 sum header was not found, invalidating local cached file!", INO_T (rdata->ino)); - cache_mng_remove_file (application_get_cache_mng (rdata->fop->app), rdata->ino); - } - } + // Check that the etag we're caching matches the AWS ETag + if (!insure_cache_etag_consistent_or_invalidate_cache(headers, rdata)) + return; // resume downloading file fileio_read_get_buf (rdata); @@ -980,10 +888,10 @@ static void fileio_read_on_head_con_cb (gpointer client, gpointer ctx) ); if (!res) { - LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (rdata->ino), con); + LOG_err (FIO_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (rdata->ino), (void *)con); http_connection_release (con); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); return; } } @@ -1005,18 +913,24 @@ void fileio_read_buffer (FileIO *fop, rdata->on_buffer_read_cb = on_buffer_read_cb; rdata->ctx = ctx; rdata->request_offset = off; + rdata->aws_etag = NULL; // send HEAD request first if (!rdata->fop->head_req_sent) { + rdata->cache_etag_is_set = FALSE; // get HTTP connection to download manifest or a full file if (!client_pool_get_client (application_get_read_client_pool (rdata->fop->app), fileio_read_on_head_con_cb, rdata)) { LOG_err (FIO_LOG, INO_H"Failed to get HTTP client !", INO_T (rdata->ino)); rdata->on_buffer_read_cb (rdata->ctx, FALSE, NULL, 0); - g_free (rdata); + fileread_destroy (rdata); } // HEAD is sent, try to get data from cache } else { + if (cache_mng_get_etag (application_get_cache_mng (rdata->fop->app), rdata->ino)) + rdata->cache_etag_is_set = TRUE; + else + rdata->cache_etag_is_set = FALSE; fileio_read_get_buf (rdata); } } @@ -1060,7 +974,7 @@ static void fileio_simple_upload_on_con_cb (gpointer client, gpointer ctx) char time_str[50]; gboolean res; - LOG_debug (FIO_LOG, CON_H"Uploading data. Size: %zu", con, evbuffer_get_length (fsim->write_buf)); + LOG_debug (FIO_LOG, CON_H"Uploading data. Size: %zu", (void *)con, evbuffer_get_length (fsim->write_buf)); http_connection_acquire (con); @@ -1081,7 +995,7 @@ static void fileio_simple_upload_on_con_cb (gpointer client, gpointer ctx) ); if (!res) { - LOG_err (FIO_LOG, CON_H"Failed to create HTTP request !", con); + LOG_err (FIO_LOG, CON_H"Failed to create HTTP request !", (void *)con); http_connection_release (con); fsim->on_upload_cb (fsim->ctx, FALSE); fileio_simple_upload_destroy (fsim); @@ -1142,7 +1056,7 @@ static void fileio_simple_download_on_con_cb (gpointer client, gpointer ctx) FileIOSimpleDownload *fsim = (FileIOSimpleDownload *) ctx; gboolean res; - LOG_debug (FIO_LOG, CON_H"Downloading data.", con); + LOG_debug (FIO_LOG, CON_H"Downloading data.", (void *)con); http_connection_acquire (con); @@ -1155,7 +1069,7 @@ static void fileio_simple_download_on_con_cb (gpointer client, gpointer ctx) ); if (!res) { - LOG_err (FIO_LOG, CON_H"Failed to create HTTP request !", con); + LOG_err (FIO_LOG, CON_H"Failed to create HTTP request !", (void *)con); http_connection_release (con); fsim->on_download_cb (fsim->ctx, FALSE, NULL, 0); fileio_simple_download_destroy (fsim); diff --git a/src/http_connection.c b/src/http_connection.c index ca1d7fa..af1364a 100644 --- a/src/http_connection.c +++ b/src/http_connection.c @@ -73,7 +73,7 @@ gpointer http_connection_create (Application *app) static gboolean http_connection_init (HttpConnection *con) { - LOG_debug (CON_LOG, CON_H"Connecting to %s:%d", con, + LOG_debug (CON_LOG, CON_H"Connecting to %s:%d", (void *)con, conf_get_string (application_get_conf (con->app), "s3.host"), conf_get_int (application_get_conf (con->app), "s3.port") ); @@ -90,7 +90,7 @@ static gboolean http_connection_init (HttpConnection *con) ssl = SSL_new (application_get_ssl_ctx (con->app)); if (!ssl) { - LOG_err (CON_LOG, CON_H"Failed to create SSL connection: %s", con, + LOG_err (CON_LOG, CON_H"Failed to create SSL connection: %s", (void *)con, ERR_reason_error_string (ERR_get_error ())); return FALSE; } @@ -103,7 +103,7 @@ static gboolean http_connection_init (HttpConnection *con) ); if (!bev) { - LOG_err (CON_LOG, CON_H"Failed to create SSL connection !", con); + LOG_err (CON_LOG, CON_H"Failed to create SSL connection !", (void *)con); return FALSE; } @@ -171,7 +171,7 @@ gboolean http_connection_acquire (HttpConnection *con) { con->is_acquired = TRUE; - LOG_debug (CON_LOG, CON_H"Connection object is acquired!", con); + LOG_debug (CON_LOG, CON_H"Connection object is acquired!", (void *)con); return TRUE; } @@ -180,7 +180,7 @@ gboolean http_connection_release (HttpConnection *con) { con->is_acquired = FALSE; - LOG_debug (CON_LOG, CON_H"Connection object is released!", con); + LOG_debug (CON_LOG, CON_H"Connection object is released!", (void *)con); if (con->client_on_released_cb) con->client_on_released_cb (con, con->pool_ctx); @@ -193,7 +193,7 @@ static void http_connection_on_close (G_GNUC_UNUSED struct evhttp_connection *ev { HttpConnection *con = (HttpConnection *) ctx; - LOG_debug (CON_LOG, CON_H"Connection closed !", con); + LOG_debug (CON_LOG, CON_H"Connection closed !", (void *)con); //con->cur_cmd_type = CMD_IDLE; @@ -352,7 +352,7 @@ static gchar *parse_aws_error (const char *xml, size_t xml_len) { typedef struct { HttpConnection *con; - HttpConnection_responce_cb responce_cb; + HttpConnection_response_cb response_cb; gpointer ctx; // number of redirects so far @@ -381,7 +381,7 @@ static void request_data_free (RequestData *data) g_free (data); } -static void http_connection_on_responce_cb (struct evhttp_request *req, void *ctx) +static void http_connection_on_response_cb (struct evhttp_request *req, void *ctx) { RequestData *data = (RequestData *) ctx; HttpConnection *con; @@ -449,7 +449,7 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct } s_history = g_strdup_printf ("[%p] %s (%u sec) %s %s %s HTTP Code: %d (Sent: %zu Received: %zu bytes)", - con, + (void *)con, ts, diff_sec, data->http_cmd, data->con->cur_url, range_str ? range_str : "", con->cur_code, @@ -461,10 +461,10 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct g_free (s_history); LOG_debug (CON_LOG, CON_H"Got HTTP response from server! (%"G_GUINT64_FORMAT"msec)", - con, timeval_diff (&data->start_tv, &end_tv)); + (void *)con, timeval_diff (&data->start_tv, &end_tv)); if (!req) { - LOG_err (CON_LOG, CON_H"Request failed !", con); + LOG_err (CON_LOG, CON_H"Request failed !", (void *)con); con->errors_nr++; #ifdef SSL_ENABLED @@ -472,7 +472,7 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct while ((oslerr = bufferevent_get_openssl_error (evhttp_connection_get_bufferevent (data->con->evcon)))) { char b[128]; ERR_error_string_n (oslerr, b, sizeof (b)); - LOG_err (CON_LOG, CON_H"SSL error: %s", con, b); + LOG_err (CON_LOG, CON_H"SSL error: %s", (void *)con, b); } } #endif @@ -480,36 +480,36 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct if (data->enable_retry) { data->retry_id++; LOG_err (CON_LOG, CON_H"Server returned HTTP error ! Retry ID: %d of %d", - con, data->retry_id, + (void *)con, data->retry_id, conf_get_int (application_get_conf (data->con->app), "connection.max_retries")); if (data->retry_id >= conf_get_int (application_get_conf (data->con->app), "connection.max_retries")) { - LOG_err (CON_LOG, CON_H"Reached the maximum number of retries !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Reached the maximum number of retries !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } else { if (!http_connection_make_request (data->con, data->resource_path, data->http_cmd, data->out_buffer, data->enable_retry, data, - data->responce_cb, data->ctx)) { - LOG_err (CON_LOG, CON_H"Failed to send request !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + data->response_cb, data->ctx)) { + LOG_err (CON_LOG, CON_H"Failed to send request !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } else { return; } } } else { - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } goto done; } // check if we reached maximum redirect count if (data->redirects > conf_get_int (application_get_conf (data->con->app), "connection.max_redirects")) { - LOG_err (CON_LOG, CON_H"Too many redirects !", con); + LOG_err (CON_LOG, CON_H"Too many redirects !", (void *)con); con->errors_nr++; - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); goto done; } @@ -534,18 +534,18 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct free_loc = TRUE; if (!loc) { - LOG_err (CON_LOG, CON_H"Redirect URL not found !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Redirect URL not found !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); goto done; } } - LOG_debug (CON_LOG, CON_H"New URL: %s", con, loc); + LOG_debug (CON_LOG, CON_H"New URL: %s", (void *)con, loc); if (!application_set_url (data->con->app, loc)) { - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); goto done; } @@ -554,17 +554,17 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct xmlFree ((char *)loc); if (!http_connection_init (data->con)) { - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); goto done; } // re-send request if (!http_connection_make_request (data->con, data->resource_path, data->http_cmd, data->out_buffer, data->enable_retry, data, - data->responce_cb, data->ctx)) { - LOG_err (CON_LOG, CON_H"Failed to send request !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + data->response_cb, data->ctx)) { + LOG_err (CON_LOG, CON_H"Failed to send request !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } else { return; } @@ -588,7 +588,7 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct msg = parse_aws_error (buf, buf_len); LOG_debug (CON_LOG, CON_H"Server returned HTTP error: %d (%s). AWS message: %s", - con, evhttp_request_get_response_code (req), req->response_code_line, msg); + (void *)con, evhttp_request_get_response_code (req), req->response_code_line, msg); if (msg) xmlFree (msg); @@ -598,35 +598,35 @@ static void http_connection_on_responce_cb (struct evhttp_request *req, void *ct if (data->enable_retry) { data->retry_id++; LOG_err (CON_LOG, CON_H"Server returned HTTP error: %d (%s)! Retry ID: %d of %d", - con, evhttp_request_get_response_code (req), req->response_code_line, data->retry_id, + (void *)con, evhttp_request_get_response_code (req), req->response_code_line, data->retry_id, conf_get_int (application_get_conf (data->con->app), "connection.max_retries")); if (data->retry_id >= conf_get_int (application_get_conf (data->con->app), "connection.max_retries")) { - LOG_err (CON_LOG, CON_H"Reached the maximum number of retries !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Reached the maximum number of retries !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } else { if (!http_connection_make_request (data->con, data->resource_path, data->http_cmd, data->out_buffer, data->enable_retry, data, - data->responce_cb, data->ctx)) { - LOG_err (CON_LOG, CON_H"Failed to send request !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + data->response_cb, data->ctx)) { + LOG_err (CON_LOG, CON_H"Failed to send request !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } else { return; } } } else { - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); } goto done; } - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, TRUE, buf, buf_len, evhttp_request_get_input_headers (req)); + if (data->response_cb) + data->response_cb (data->con, data->ctx, TRUE, buf, buf_len, evhttp_request_get_input_headers (req)); else - LOG_debug (CON_LOG, CON_H"NO callback function !", con); + LOG_debug (CON_LOG, CON_H"NO callback function !", (void *)con); done: request_data_free (data); @@ -666,7 +666,7 @@ gboolean http_connection_make_request (HttpConnection *con, const gchar *http_cmd, struct evbuffer *out_buffer, gboolean enable_retry, gpointer parent_request_data, - HttpConnection_responce_cb responce_cb, + HttpConnection_response_cb response_cb, gpointer ctx) { gchar *auth_str; @@ -684,9 +684,9 @@ gboolean http_connection_make_request (HttpConnection *con, if (!con->evcon) if (!http_connection_init (con)) { - LOG_err (CON_LOG, CON_H"Failed to init HTTP connection !", con); - if (responce_cb) - responce_cb (con, ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Failed to init HTTP connection !", (void *)con); + if (response_cb) + response_cb (con, ctx, FALSE, NULL, 0, NULL); return FALSE; } @@ -734,7 +734,7 @@ gboolean http_connection_make_request (HttpConnection *con, } else data = (RequestData *) parent_request_data; - data->responce_cb = responce_cb; + data->response_cb = response_cb; data->ctx = ctx; data->con = con; @@ -749,18 +749,18 @@ gboolean http_connection_make_request (HttpConnection *con, } else if (!strcasecmp (http_cmd, "HEAD")) { cmd_type = EVHTTP_REQ_HEAD; } else { - LOG_err (CON_LOG, CON_H"Unsupported HTTP method: %s", con, http_cmd); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Unsupported HTTP method: %s", (void *)con, http_cmd); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); request_data_free (data); return FALSE; } t = time (NULL); if (!strftime (time_str, sizeof (time_str), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&t))) { - LOG_err (CON_LOG, CON_H"strftime returned error !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"strftime returned error !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); request_data_free (data); return FALSE; } @@ -769,11 +769,11 @@ gboolean http_connection_make_request (HttpConnection *con, snprintf (auth_key, sizeof (auth_key), "AWS %s:%s", conf_get_string (application_get_conf (con->app), "s3.access_key_id"), auth_str); g_free (auth_str); - req = evhttp_request_new (http_connection_on_responce_cb, data); + req = evhttp_request_new (http_connection_on_response_cb, data); if (!req) { - LOG_err (CON_LOG, CON_H"Failed to create HTTP request object !", con); - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + LOG_err (CON_LOG, CON_H"Failed to create HTTP request object !", (void *)con); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); request_data_free (data); return FALSE; } @@ -809,7 +809,7 @@ gboolean http_connection_make_request (HttpConnection *con, request_str = g_strdup_printf ("/%s%s", bucket_name, data->resource_path); } - LOG_msg (CON_LOG, CON_H"%s %s bucket: %s, host: %s, out_len: %zd", con, + LOG_msg (CON_LOG, CON_H"%s %s bucket: %s, host: %s, out_len: %zd", (void *)con, http_cmd, request_str, bucket_name, host, out_buffer ? evbuffer_get_length (out_buffer) : 0); @@ -827,8 +827,8 @@ gboolean http_connection_make_request (HttpConnection *con, g_free (request_str); if (res < 0) { - if (data->responce_cb) - data->responce_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); + if (data->response_cb) + data->response_cb (data->con, data->ctx, FALSE, NULL, 0, NULL); request_data_free (data); return FALSE; } else @@ -906,7 +906,7 @@ void http_connection_get_stats_info_data (gpointer client, GString *str, struct "%s" // footer , print_format->row_start, - con, print_format->col_div, + (void *)con, print_format->col_div, con->is_acquired ? "Busy" : "Idle", print_format->col_div, cmd, print_format->col_div, con->cur_url ? con->cur_url : "-", print_format->col_div, diff --git a/src/http_connection_dir_list.c b/src/http_connection_dir_list.c index e35e7da..2fe0428 100644 --- a/src/http_connection_dir_list.c +++ b/src/http_connection_dir_list.c @@ -298,19 +298,19 @@ static void http_connection_on_directory_listing_data (HttpConnection *con, void gboolean res; if (!buf_len || !buf) { - LOG_err (CON_DIR_LOG, INO_CON_H"Directory buffer is empty !", INO_T (dir_req->ino), con); + LOG_err (CON_DIR_LOG, INO_CON_H"Directory buffer is empty !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, FALSE); return; } if (!success) { - LOG_err (CON_DIR_LOG, INO_CON_H"Error getting directory list !", INO_T (dir_req->ino), con); + LOG_err (CON_DIR_LOG, INO_CON_H"Error getting directory list !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, FALSE); return; } if (!parse_dir_xml (dir_req, buf, buf_len)) { - LOG_err (CON_DIR_LOG, INO_CON_H"Error parsing directory XML !", INO_T (dir_req->ino), con); + LOG_err (CON_DIR_LOG, INO_CON_H"Error parsing directory XML !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, FALSE); return; } @@ -320,7 +320,7 @@ static void http_connection_on_directory_listing_data (HttpConnection *con, void // check if we need to get more data if (!g_strstr_len (buf, buf_len, "true") && !next_marker) { - LOG_debug (CON_DIR_LOG, INO_CON_H"Directory listing done !", INO_T (dir_req->ino), con); + LOG_debug (CON_DIR_LOG, INO_CON_H"Directory listing done !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, TRUE); return; } @@ -339,7 +339,7 @@ static void http_connection_on_directory_listing_data (HttpConnection *con, void g_free (req_path); if (!res) { - LOG_err (CON_DIR_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (dir_req->ino), con); + LOG_err (CON_DIR_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, FALSE); return; } @@ -353,7 +353,7 @@ void http_connection_get_directory_listing (HttpConnection *con, const gchar *di gchar *req_path; gboolean res; - LOG_debug (CON_DIR_LOG, INO_CON_H"Getting directory listing for: >>%s<<", INO_T (con), con, dir_path); + LOG_debug (CON_DIR_LOG, INO_CON_H"Getting directory listing for: >>%s<<", INO_T (con), (void *)con, dir_path); dir_req = g_new0 (DirListRequest, 1); dir_req->con = con; @@ -386,7 +386,7 @@ void http_connection_get_directory_listing (HttpConnection *con, const gchar *di g_free (req_path); if (!res) { - LOG_err (CON_DIR_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (dir_req->ino), con); + LOG_err (CON_DIR_LOG, INO_CON_H"Failed to create HTTP request !", INO_T (dir_req->ino), (void *)con); directory_listing_done (con, dir_req, FALSE); return; } diff --git a/src/main.c b/src/main.c index e78583d..27e418c 100644 --- a/src/main.c +++ b/src/main.c @@ -289,7 +289,7 @@ static void sigusr1_cb (G_GNUC_UNUSED evutil_socket_t sig, G_GNUC_UNUSED short e LOG_err (APP_LOG, "Failed to parse configuration file: %s", _app->conf_path); conf_destroy(conf_new); } else { - const gchar *copy_entries[] = {"s3.host", "s3.port", "s3.versioning", "s3.access_key_id", "s3.secret_access_key", "s3.bucket_name", NULL}; + const gchar *copy_entries[] = {"s3.host", "s3.port", "s3.access_key_id", "s3.secret_access_key", "s3.bucket_name", NULL}; int i; _app->conf = conf_new; @@ -483,39 +483,6 @@ static gint application_finish_initialization_and_run (Application *app) } /*}}}*/ -/*{{{ application_on_bucket_versioning_cb */ -// replies on bucket versioning information -static void application_on_bucket_versioning_cb (gpointer ctx, gboolean success, - const gchar *buf, size_t buf_len) -{ - Application *app = (Application *)ctx; - gchar *tmp; - - if (!success) { - LOG_err (APP_LOG, "Failed to get bucket versioning!"); - application_exit (app); - return; - } - - if (buf_len > 1) { - tmp = (gchar *)buf; - tmp[buf_len - 1] = '\0'; - - if (strstr (buf, "Enabled")) { - LOG_debug (APP_LOG, "Bucket has versioning enabled !"); - conf_set_boolean (app->conf, "s3.versioning", TRUE); - } else { - LOG_debug (APP_LOG, "Bucket has versioning disabled !"); - conf_set_boolean (app->conf, "s3.versioning", FALSE); - } - } else { - conf_set_boolean (app->conf, "s3.versioning", FALSE); - } - - application_finish_initialization_and_run (app); -} -/*}}}*/ - /*{{{ application_on_bucket_acl_cb */ // replies on bucket ACL static void application_on_bucket_acl_cb (gpointer ctx, gboolean success, @@ -531,7 +498,7 @@ static void application_on_bucket_acl_cb (gpointer ctx, gboolean success, // XXX: check ACL permissions - bucket_client_get (app->service_con, "/?versioning", application_on_bucket_versioning_cb, app); + application_finish_initialization_and_run (app); } /*}}}*/ diff --git a/src/rfuse.c b/src/rfuse.c index 7c96e01..7d7022e 100644 --- a/src/rfuse.c +++ b/src/rfuse.c @@ -617,7 +617,7 @@ static void rfuse_open (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *f { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, INO_FI_H"open inode, flags: %d", INO_T (ino), fi, fi->flags); + LOG_debug (FUSE_LOG, INO_FI_H"open inode, flags: %d", INO_T (ino), (void *)fi, fi->flags); dir_tree_file_open (rfuse->dir_tree, ino, fi, rfuse_open_cb, req); } @@ -630,7 +630,7 @@ void rfuse_create_cb (fuse_req_t req, gboolean success, fuse_ino_t ino, int mode struct fuse_entry_param e; RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, INO_FI_H"add_file_cb success: %s", INO_T (ino), fi, success?"YES":"NO"); + LOG_debug (FUSE_LOG, INO_FI_H"add_file_cb success: %s", INO_T (ino), (void *)fi, success?"YES":"NO"); if (!success) { fuse_reply_err (req, ENOENT); return; @@ -673,7 +673,7 @@ static void rfuse_release (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, INO_FI_H"release inode, flags: %d", INO_T (ino), fi, fi->flags); + LOG_debug (FUSE_LOG, INO_FI_H"release inode, flags: %d", INO_T (ino), (void *)fi, fi->flags); dir_tree_file_release (rfuse->dir_tree, ino, fi); @@ -687,7 +687,7 @@ static void rfuse_release (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info static void rfuse_read_cb (fuse_req_t req, gboolean success, const char *buf, size_t buf_size) { - LOG_debug (FUSE_LOG, "[req: %p] <<<<< read_cb success: %s IN buf: %zu", req, success?"YES":"NO", buf_size); + LOG_debug (FUSE_LOG, "[req: %p] <<<<< read_cb success: %s IN buf: %zu", (void *)req, success?"YES":"NO", buf_size); if (!success) { fuse_reply_err (req, ENOENT); @@ -703,7 +703,7 @@ static void rfuse_read (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, INO_FI_H">>>> read inode, size: %zu, off: %"OFF_FMT, INO_T (ino), fi, size, off); + LOG_debug (FUSE_LOG, INO_FI_H">>>> read inode, size: %zu, off: %"OFF_FMT, INO_T (ino), (void *)fi, size, off); rfuse->read_ops++; dir_tree_file_read (rfuse->dir_tree, ino, size, off, rfuse_read_cb, req, fi); @@ -714,7 +714,7 @@ static void rfuse_read (fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, // write callback static void rfuse_write_cb (fuse_req_t req, gboolean success, size_t count) { - LOG_debug (FUSE_LOG, "[req: %p] write_cb success: %s", req, success?"YES":"NO"); + LOG_debug (FUSE_LOG, "[req: %p] write_cb success: %s", (void *)req, success?"YES":"NO"); if (!success) { fuse_reply_err (req, ENOENT); @@ -729,7 +729,7 @@ static void rfuse_write (fuse_req_t req, fuse_ino_t ino, const char *buf, size_t { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, INO_FI_H"write inode, size: %zu, off: %"OFF_FMT, INO_T (ino), fi, size, off); + LOG_debug (FUSE_LOG, INO_FI_H"write inode, size: %zu, off: %"OFF_FMT, INO_T (ino), (void *)fi, size, off); rfuse->write_ops++; dir_tree_file_write (rfuse->dir_tree, ino, buf, size, off, rfuse_write_cb, req, fi); @@ -768,7 +768,7 @@ static void rfuse_forget (fuse_req_t req, fuse_ino_t ino, unsigned long nlookup) static void rfuse_unlink_cb (fuse_req_t req, gboolean success) { - LOG_debug (FUSE_LOG, "[%p] success: %s", req, success ? "TRUE" : "FALSE"); + LOG_debug (FUSE_LOG, "[%p] success: %s", (void *)req, success ? "TRUE" : "FALSE"); if (success) fuse_reply_err (req, 0); @@ -783,7 +783,7 @@ static void rfuse_unlink (fuse_req_t req, fuse_ino_t parent, const char *name) { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, "[%p] unlink parent_ino: %"INO_FMT", name: %s", req, INO parent, name); + LOG_debug (FUSE_LOG, "[%p] unlink parent_ino: %"INO_FMT", name: %s", (void *)req, INO parent, name); dir_tree_file_unlink (rfuse->dir_tree, parent, name, rfuse_unlink_cb, req); } @@ -843,7 +843,7 @@ static void rfuse_rmdir (fuse_req_t req, fuse_ino_t parent_ino, const char *name { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, "[%p] rmdir parent_ino: %"INO_FMT", name: %s", rfuse, INO parent_ino, name); + LOG_debug (FUSE_LOG, "[%p] rmdir parent_ino: %"INO_FMT", name: %s", (void *)rfuse, INO parent_ino, name); // notify dir tree if (dir_tree_dir_remove (rfuse->dir_tree, parent_ino, name, req)) @@ -902,7 +902,7 @@ static void rfuse_listxattr (fuse_req_t req, fuse_ino_t ino, size_t size) static void rfuse_getxattr_cb (fuse_req_t req, gboolean success, fuse_ino_t ino, const gchar *str, size_t size) { - LOG_debug (FUSE_LOG, INO_H"getattr_cb success: %s str: %s", INO_T (ino), success?"YES":"NO", str); + LOG_debug (FUSE_LOG, INO_H"getxattr_cb success: %s str: %s", INO_T (ino), success?"YES":"NO", str); if (!success || !str) { fuse_reply_err (req, ENOTSUP); @@ -997,7 +997,7 @@ static void rfuse_symlink (fuse_req_t req, const char *link, fuse_ino_t parent_i { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, "[%p] symlink parent_ino: %"INO_FMT", name: %s link: %s", rfuse, INO parent_ino, name, link); + LOG_debug (FUSE_LOG, "[%p] symlink parent_ino: %"INO_FMT", name: %s link: %s", (void *)rfuse, INO parent_ino, name, link); dir_tree_create_symlink (rfuse->dir_tree, parent_ino, name, link, rfuse_symlik_cb, req); } @@ -1020,7 +1020,7 @@ static void rfuse_readlink (fuse_req_t req, fuse_ino_t ino) { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, "[%p] readlink ino: %"INO_FMT, rfuse, INO ino); + LOG_debug (FUSE_LOG, "[%p] readlink ino: %"INO_FMT, (void *)rfuse, INO ino); dir_tree_readlink (rfuse->dir_tree, ino, rfuse_readlink_cb, req); } @@ -1030,7 +1030,7 @@ static void rfuse_readlink (fuse_req_t req, fuse_ino_t ino) // XXX: currently just a placeholder, does nothing static void rfuse_flush_cb (fuse_req_t req, gboolean success) { - LOG_debug (FUSE_LOG, "[req: %p] flush_cb success: %s", req, success?"YES":"NO"); + LOG_debug (FUSE_LOG, "[req: %p] flush_cb success: %s", (void *)req, success?"YES":"NO"); if (!success) { fuse_reply_err (req, ENOENT); @@ -1040,11 +1040,11 @@ static void rfuse_flush_cb (fuse_req_t req, gboolean success) fuse_reply_err (req, 0); } -static void rfuse_flush (fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) +static void rfuse_flush (fuse_req_t req, fuse_ino_t ino, G_GNUC_UNUSED struct fuse_file_info *fi) { RFuse *rfuse = fuse_req_userdata (req); - LOG_debug (FUSE_LOG, "[%p][req: %p] flush ino: %"INO_FMT, rfuse, req, INO ino); + LOG_debug (FUSE_LOG, "[%p][req: %p] flush ino: %"INO_FMT, (void *)rfuse, (void *)req, INO ino); rfuse_flush_cb (req, TRUE); } diff --git a/tests/test_io.py b/tests/test_io.py index 5dc9351..b35389a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 from subprocess import Popen, PIPE from StringIO import StringIO