Skip to content

Commit

Permalink
Added "none" status returned, otherwise session would hang waiting fo…
Browse files Browse the repository at this point in the history
…r a response when TYPE is used on a non-existent object (#150)
  • Loading branch information
cduluCNB authored Apr 1, 2024
1 parent ca3fde0 commit b33189f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/server/Resp/ArrayCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ private bool NetworkTYPE<TGarnetApi>(int count, byte* ptr, ref TGarnetApi storag
while (!RespWriteUtils.WriteSimpleString(Encoding.ASCII.GetBytes(typeName), ref dcurr, dend))
SendAndReset();
}
else
{
while (!RespWriteUtils.WriteSimpleString(Encoding.ASCII.GetBytes(@"none"), ref dcurr, dend))
SendAndReset();
}

readHead = (int)(ptr - recvBufferPtr);
return true;
Expand Down
6 changes: 6 additions & 0 deletions libs/server/Storage/Session/MainStore/MainStoreOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ public GarnetStatus GetKeyType<TContext, TObjectContext>(ArgSlice key, out strin
if (status != GarnetStatus.OK && objectStoreSession != null)
{
status = GET(key.Bytes, out GarnetObjectStoreOutput output, ref objectContext);

if (status == GarnetStatus.OK)
{
if ((output.garnetObject as SortedSetObject) != null)
Expand All @@ -885,6 +886,11 @@ public GarnetStatus GetKeyType<TContext, TObjectContext>(ArgSlice key, out strin
keyType = "hash";
}
}
else
{
keyType = "none";
status = GarnetStatus.NOTFOUND;
}
}
return status;
}
Expand Down

0 comments on commit b33189f

Please sign in to comment.