@@ -256,13 +256,14 @@ void hashTypePropagateDeletion(serverDb *db, sds key, void *entry) {
256256}
257257
258258int hashTypeExpireEntry (void * entry ) {
259- serverAssert (server .access_context .key && server .access_context .db );
260- robj keyobj ;
261- sds key = objectGetKey (server .access_context .key );
262- serverAssert (key );
263- initStaticStringObject (keyobj , key );
264- notifyKeyspaceEvent (NOTIFY_EXPIRED , "hexpired" , & keyobj , server .access_context .db -> id );
265- serverLog (LL_NOTICE , "expiring entry %s of key %s" , (sds )entry , key );
259+ serverAssert (server .access_context .val && server .access_context .db );
260+ robj * keyobj = server .access_context .key ;
261+ robj * o = server .access_context .val ;
262+ sds key = objectGetKey (o );
263+ if (!keyobj ) {
264+ keyobj = createStringObject (key , sdslen (key ));
265+ }
266+ notifyKeyspaceEvent (NOTIFY_EXPIRED , "hexpired" , keyobj , server .access_context .db -> id );
266267 hashTypePropagateDeletion (server .access_context .db , key , entry );
267268 return 1 ;
268269}
@@ -295,20 +296,23 @@ hashtableElementAccessState hashHashtableTypeAccess(hashtable *ht, void *entry)
295296 return ELEMENT_DELETE ;
296297}
297298
298- void hashTypeSetAccessContext (robj * o , serverDb * db ) {
299- setAccessContext (o , db );
299+ void hashTypeSetAccessContext (robj * key , robj * val , serverDb * db ) {
300+ setAccessContext (key , val , db );
300301}
301302
302303void hashTypeResetAccessContext (void ) {
303- robj keyobj ;
304- robj * o = server .access_context .key ;
304+ robj * keyobj = server . access_context . key ;
305+ robj * o = server .access_context .val ;
305306 serverDb * db = server .access_context .db ;
306307 serverAssert (!o || o -> type == OBJ_HASH );
307308 resetAccessContext ();
308309 if (o ) {
309310 if (hashTypeLength (o ) == 0 ) {
310- initStaticStringObject (keyobj , objectGetKey (o ));
311- notifyKeyspaceEvent (NOTIFY_GENERIC , "del" , & keyobj , db -> id );
311+ if (!keyobj ) {
312+ sds key = objectGetKey (o );
313+ keyobj = createStringObject (key , sdslen (key ));
314+ }
315+ notifyKeyspaceEvent (NOTIFY_GENERIC , "del" , keyobj , db -> id );
312316 dbDelete (db , & keyobj );
313317 }
314318 }
@@ -1043,7 +1047,7 @@ void hincrbyCommand(client *c) {
10431047
10441048 if (getLongLongFromObjectOrReply (c , c -> argv [3 ], & incr , NULL ) != C_OK ) return ;
10451049 if ((o = hashTypeLookupWriteOrCreate (c , c -> argv [1 ])) == NULL ) return ;
1046- hashTypeSetAccessContext (o , c -> db );
1050+ hashTypeSetAccessContext (c -> argv [ 1 ], o , c -> db );
10471051 if (hashTypeGetValue (o , c -> argv [2 ]-> ptr , & vstr , & vlen , & value ) == C_OK ) {
10481052 if (vstr ) {
10491053 if (string2ll ((char * )vstr , vlen , & value ) == 0 ) {
@@ -1169,7 +1173,7 @@ void hmgetCommand(client *c) {
11691173
11701174 if (checkType (c , o , OBJ_HASH )) return ;
11711175
1172- hashTypeSetAccessContext (o , c -> db );
1176+ hashTypeSetAccessContext (c -> argv [ 1 ], o , c -> db );
11731177
11741178 addReplyArrayLen (c , c -> argc - 2 );
11751179 for (i = 2 ; i < c -> argc ; i ++ ) {
@@ -1214,7 +1218,7 @@ void hstrlenCommand(client *c) {
12141218 robj * o ;
12151219
12161220 if ((o = lookupKeyReadOrReply (c , c -> argv [1 ], shared .czero )) == NULL || checkType (c , o , OBJ_HASH )) return ;
1217- hashTypeSetAccessContext (o , c -> db );
1221+ hashTypeSetAccessContext (c -> argv [ 1 ], o , c -> db );
12181222 addReplyLongLong (c , hashTypeGetValueLength (o , c -> argv [2 ]-> ptr ));
12191223 hashTypeResetAccessContext ();
12201224}
0 commit comments