MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getTimeoutFromObjectOrReply

Function getTimeoutFromObjectOrReply

app/redis-6.2.6/src/timeout.c:164–190  ·  view source on GitHub ↗

Get a timeout value from an object and store it into 'timeout'. * The final timeout is always stored as milliseconds as a time where the * timeout will expire, however the parsing is performed according to * the 'unit' that can be seconds or milliseconds. * * Note that if the timeout is zero (usually from the point of view of * commands API this means no timeout) the value stored into 'timeo

Source from the content-addressed store, hash-verified

162 * commands API this means no timeout) the value stored into 'timeout'
163 * is zero. */
164int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int unit) {
165 long long tval;
166 long double ftval;
167
168 if (unit == UNIT_SECONDS) {
169 if (getLongDoubleFromObjectOrReply(c,object,&ftval,
170 "timeout is not a float or out of range") != C_OK)
171 return C_ERR;
172 tval = (long long) (ftval * 1000.0);
173 } else {
174 if (getLongLongFromObjectOrReply(c,object,&tval,
175 "timeout is not an integer or out of range") != C_OK)
176 return C_ERR;
177 }
178
179 if (tval < 0) {
180 addReplyError(c,"timeout is negative");
181 return C_ERR;
182 }
183
184 if (tval > 0) {
185 tval += mstime();
186 }
187 *timeout = tval;
188
189 return C_OK;
190}

Callers 7

waitCommandFunction · 0.85
clientCommandFunction · 0.85
xreadCommandFunction · 0.85
blmoveCommandFunction · 0.85
brpoplpushCommandFunction · 0.85

Calls 4

addReplyErrorFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected