Problems with using pipe(...); on select(...);
My problem is as follows:
I'm trying to wake up a select(...); using a pipe fd. This should be rather straightforward, but I cannot get it to work. Perhaps you guys could give me a few tips.
My wakeup function looks like this:
This pipe is created using:
STATIC void net_trig_wr()
/* write a dummy to wake up net thread */
write(net_pipefd, _T("TRIG"), 4);
ALLEGE(pipe(pipe_set) == 0);
net_pipefd = pipe_set;
And the net_rd_set is the set select uses:
Of course the maxfd is set to:
ALLEGE((res = select(maxfd+1, &net_rd_set, &net_wr_set, NULL, NULL)) != -1);
It should be noted net_trig_wr(); is called from another thread (created using POSIX-threads) than the select(...) operates in.
maxfd = pipe_set;
I've attached the entire net.c file (as net.txt) in this document. So if you want to have a look at it to help me further. Feel free to get inspired by my code also (if there is anything to get inspired by).
Any tips would be usefull!
/ Henrik, Sweden
(For the intressted, im actually rewriting a Java-server I've done for www.betapet.com which is a free swedish scrabble-site)