On Wed, Feb 25, 2015 at 10:49 AM, Ted Ross <[email protected]> wrote: > Would it be safe to assume that any operations on driver->io are not > thread safe? > > Dispatch is a multi-threaded application. It looks to me as though > io->error is a resource shared across the threads in an unsafe way. >
Interesting... so this is what the docs say: /** * A ::pn_io_t manages IO for a group of pn_socket_t handles. A * pn_io_t object may have zero or one pn_selector_t selectors * associated with it (see ::pn_io_selector()). If one is associated, * all the pn_socket_t handles managed by a pn_io_t must use that * pn_selector_t instance. * * The pn_io_t interface is single-threaded. All methods are intended * to be used by one thread at a time, except that multiple threads * may use: * * ::pn_write() * ::pn_send() * ::pn_recv() * ::pn_close() * ::pn_selector_select() * * provided at most one thread is calling ::pn_selector_select() and * the other threads are operating on separate pn_socket_t handles. */ I think this has been somewhat modified by the constraints from the windows implementation, and I'm not sure I understand completely what the constraints are there, or entirely what is being described above, but on the posix front, the pn_io_t is little more than just a holder for an error slot, and you should have one of these per thread. It shouldn't be a problem to use send/recv/etc from multiple threads though so long as you pass in the pn_io_t from the current thread. --Rafael
