converted local_process_batch into tail call recusion

Change-Id: If7e9e88b3d9294320a90de14a172df718297ba43
Reviewed-on: http://review.couchbase.org/37558
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Artamonau <aliaksiej.artamonau@gmail.com>