Add 'poll' event implementation.  Fix a nasty bug in event.c.

Nasty bug: adding a callback to an existing io_event but for a different state overwrote any callbacks you'd already registered! Bad.