From: Michael Vrable Date: Wed, 18 Nov 2009 06:33:55 +0000 (-0800) Subject: Better checks for non-existent inodes. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=dc5933ed00033bde61c68a88606a54c423257f5a;p=bluesky.git Better checks for non-existent inodes. --- diff --git a/bluesky/inode.c b/bluesky/inode.c index 12cf7f7..44ef63c 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -170,6 +170,10 @@ BlueSkyInode *bluesky_get_inode(BlueSkyFS *fs, uint64_t inum) { BlueSkyInode *inode = NULL; + if (inum == 0) { + return NULL; + } + g_mutex_lock(fs->lock); inode = (BlueSkyInode *)g_hash_table_lookup(fs->inodes, &inum); @@ -232,4 +236,3 @@ void bluesky_superblock_flush(BlueSkyFS *fs) bluesky_store_put(fs->store, "superblock", data); } - diff --git a/bluesky/s3store.c b/bluesky/s3store.c index 1a9e6b9..2e1eb17 100644 --- a/bluesky/s3store.c +++ b/bluesky/s3store.c @@ -61,6 +61,7 @@ static void s3store_destroy(gpointer store) } struct get_info { + int success; GString *buf; }; @@ -98,8 +99,15 @@ static void s3store_response_callback(S3Status status, const S3ErrorDetails *errorDetails, void *callbackData) { + struct get_info *info = (struct get_info *)callbackData; + g_print("S3 operation complete, status=%s, now=%ld\n", S3_get_status_name(status), bluesky_now_hires()); + + if (status == 0) { + info->success = 1; + } + if (errorDetails != NULL) { g_print(" Error message: %s\n", errorDetails->message); } @@ -111,6 +119,7 @@ static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key) struct get_info info; info.buf = g_string_new(""); + info.success = 0; struct S3GetObjectHandler handler; handler.responseHandler.propertiesCallback = s3store_properties_callback; @@ -121,6 +130,11 @@ static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key) S3_get_object(&store->bucket, key, NULL, 0, 0, NULL, &handler, &info); + if (!info.success) { + g_string_free(info.buf, TRUE); + return NULL; + } + BlueSkyRCStr *raw, *decrypted; raw = bluesky_string_new_from_gstring(info.buf); decrypted = bluesky_crypt_decrypt(raw, store->encryption_key);