Locating at: https://github.com/redis/redis/blob/e92363e248019b8bf3fc7dd8ce84f648b6b13473/src/aof.c#L1340
I think it could be put at the entrance of this function, so it could be fail ASAP if AOF_OFF.
It maybe looks like as:
void feedAppendOnlyFile(int dictid, robj ** argv, int argc) {
if (server.aof_state != AOF_ON &&
(server.aof_state != AOF_WAIT_REWRITE || server.child_type != CHILD_TYPE_AOF))
{
return;
}
// todo
}