summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--restart.c5
-rw-r--r--t/restart.t9
2 files changed, 14 insertions, 0 deletions
diff --git a/restart.c b/restart.c
index 74faf75..1ce6799 100644
--- a/restart.c
+++ b/restart.c
@@ -82,6 +82,7 @@ static int restart_check(const char *file) {
restart_cb_ctx ctx;
ctx.f = f;
+ ctx.cb = NULL;
ctx.line = NULL;
ctx.done = false;
if (restart_get_kv(&ctx, NULL, NULL) != RESTART_DONE) {
@@ -91,6 +92,10 @@ static int restart_check(const char *file) {
// TODO: this should probably just return -1 and skip the reuse.
abort();
}
+ if (ctx.cb == NULL) {
+ fprintf(stderr, "[restart] Failed to read a tag from metadata file\n");
+ abort();
+ }
// loop call the callback, check result code.
bool failed = false;
diff --git a/t/restart.t b/t/restart.t
index 74f661d..d96c32d 100644
--- a/t/restart.t
+++ b/t/restart.t
@@ -12,6 +12,15 @@ use MemcachedTest;
# /dev/shm.
my $mem_path = "/tmp/mc_restart.$$";
+# read a invalid metadata file
+{
+ my $meta_path = "$mem_path.meta";
+ open(my $f, "> $meta_path") || die("Can't open a metadata file.");
+ eval { new_memcached("-e $mem_path"); };
+ unlink($meta_path);
+ ok($@, "Died with an empty metadata file");
+}
+
my $server = new_memcached("-m 128 -e $mem_path -I 2m");
my $sock = $server->sock;