Fix holding write lock while calling notify in legacy API