Hello dear list. I have a TCP client program build around three threads : a reader, a writer, and a "connecter" that establish the connection and spawn the reader and writer. It then wait for one of them to return before cleaning and restarting. Here is the connecter loop :
void *connecter_thread(void *arg) { /* ... */ reader_pthid = pth_spawn(PTH_ATTR_DEFAULT, reader_thread, NULL); writer_pthid = pth_spawn(PTH_ATTR_DEFAULT, writer_thread, NULL); pth_event_t ev_r = pth_event(PTH_EVENT_TID|PTH_UNTIL_TID_DEAD, reader_pthid); pth_event_t ev_w = pth_event(PTH_EVENT_TID|PTH_UNTIL_TID_DEAD, writer_pthid); pth_event_t ev_ring = pth_event_concat(ev_r, ev_w, NULL); while (reader_pthid && writer_pthid) { int nonpending = pth_wait(ev_ring); debug("%d event(s) occured", nonpending); pth_event_t ev = ev_ring; do { if (pth_event_status(ev) == PTH_STATUS_OCCURRED) { debug("occuring pth event %u", (unsigned)pth_event_typeof(ev)); assert(pth_event_typeof(ev) == (PTH_EVENT_TID|PTH_UNTIL_TID_DEAD)); // FIXME: FAILS pth_t dead_one; pth_event_extract(ev, &dead_one); if (dead_one == reader_pthid) reader_pthid = NULL; if (dead_one == writer_pthid) writer_pthid = NULL; } ev = pth_event_walk(ev, PTH_WALK_NEXT); } while (ev != ev_ring); } pth_event_free(ev_ring, PTH_FREE_ALL); if (reader_pthid) (void)pth_cancel(reader_pthid); if (writer_pthid) (void)pth_cancel(writer_pthid); /* ... */ } So my ring of events is composed of two events of type PTH_EVENT_TID|PTH_UNTIL_TID_DEAD. pth_wait returns indicating that 1 event occurred, but thereafter the assertion fails because the event that occurred is of type 260, which is PTH_EVENT_TID|PTH_EVENT_SELECT. I do not understand this. The reader and writer threads do use pth_select, but this is not supposed to add an event on this threads event ring, is it ? Perhaps my program broke the event linked list for some reason, but probably I misunderstood something. Any hint, someone ? ______________________________________________________________________ GNU Portable Threads (Pth) http://www.gnu.org/software/pth/ Development Site http://www.ossp.org/pkg/lib/pth/ Distribution Files ftp://ftp.gnu.org/gnu/pth/ Distribution Snapshots ftp://ftp.ossp.org/pkg/lib/pth/ User Support Mailing List pth-users@gnu.org Automated List Manager (Majordomo) [EMAIL PROTECTED]