Hello all,
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:
Code:
STATIC void net_trig_wr()
{
/* write a dummy to wake up net thread */
write(net_pipefd, _T("TRIG"), 4);
}
This pipe is created using:
Code:
int pipe_set[2];
ALLEGE(pipe(pipe_set) == 0);
net_pipefd = pipe_set[1];
FD_SET(pipe_set[0], &net_rd_set);
And the net_rd_set is the set select uses:
Code:
ALLEGE((res = select(maxfd+1, &net_rd_set, &net_wr_set, NULL, NULL)) != -1);
Of course the maxfd is set to:
Code:
maxfd = pipe_set[0];
It should be noted net_trig_wr(); is called from another thread (created using POSIX-threads) than the select(...) operates in.
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)