Safer apipe_read_locked()

In case readers who lock externally don't check for emptiness before
reading.