MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / addReply

Function addReply

src/networking.cpp:443–460  ·  view source on GitHub ↗

----------------------------------------------------------------------------- * Higher level functions to queue data on the client output buffer. * The following functions are the ones that commands implementations will call. * -------------------------------------------------------------------------- */ Add the object 'obj' string representation to the client output buffer. */

Source from the content-addressed store, hash-verified

441 * -------------------------------------------------------------------------- */
442/* Add the object 'obj' string representation to the client output buffer. */
443void addReply(client *c, robj_roptr obj) {
444 if (prepareClientToWrite(c) != C_OK) return;
445
446 if (sdsEncodedObject(obj)) {
447 if (_addReplyToBuffer(c,(const char*)ptrFromObj(obj),sdslen((sds)ptrFromObj(obj))) != C_OK)
448 _addReplyProtoToList(c,(const char*)ptrFromObj(obj),sdslen((sds)ptrFromObj(obj)));
449 } else if (obj->encoding == OBJ_ENCODING_INT) {
450 /* For integer encoded strings we just convert it into a string
451 * using our optimized function, and attach the resulting string
452 * to the output buffer. */
453 char buf[32];
454 size_t len = ll2string(buf,sizeof(buf),(long)ptrFromObj(obj));
455 if (_addReplyToBuffer(c,buf,len) != C_OK)
456 _addReplyProtoToList(c,buf,len);
457 } else {
458 serverPanic("Wrong obj->encoding in addReply()");
459 }
460}
461
462/* Add the SDS 's' string to the client output buffer, as a side effect
463 * the SDS string is freed. */

Callers 15

SentReplyOnKeyMissFunction · 0.85
flushdbCommandFunction · 0.85
flushallCommandFunction · 0.85
selectCommandFunction · 0.85
shutdownCommandFunction · 0.85
renameGenericCommandFunction · 0.85
moveCommandFunction · 0.85
copyCommandFunction · 0.85
swapdbCommandFunction · 0.85
addReplyPubsubMessageFunction · 0.85
addReplyPubsubPatMessageFunction · 0.85
addReplyPubsubSubscribedFunction · 0.85

Calls 6

prepareClientToWriteFunction · 0.85
_addReplyToBufferFunction · 0.85
ptrFromObjFunction · 0.85
sdslenFunction · 0.85
_addReplyProtoToListFunction · 0.85
ll2stringFunction · 0.85

Tested by

no test coverage detected