r->count--; to the right place fixed my problem. Thanks agentzh again! Posted at Nginx Forum: http://forum.nginx.org/read.php?2,178511,179222#msg-179222