Xuedong Chen <Xuedong.Chen@igt.com> wrote:
Where can I find more information about rcvid? How is rcvid formed?
Different threads in the same client process should have the same rcvid or
different ones? rcvid should have nothing to do with Server, right?
You should not know “how the rcvid is formed”. It is only an int
to you. Each rcvid gurenteed that it is represent an “unique” MsgSend().
So, if different threads send though same connect, the server got
different “rcvid”.
If Server need to understand which requesting thread is associated with a
pulse, what I need to do is to compare the rcvid in the pulse with rcvid
(s) which I buffered when I received the message requests?
Yes, and there are more complicate race conditions.
In theroy, you only receive UNBLOCK pulse only if the client blocking on you.
So the rcvid in pulse should always matching one of your “buffered” rcvid.
However, pulse can be queued and delayed. So, if a client blocking on you,
and somebody “ctrl-c” it twice, you will receive 2 Unblock pulse, and in
that case, the second pulse have a rcvid not in your buffered rcvid.
Now the weired case is “if the unblock happened before you can receive it”,
or (in above case), after you MsgReply()/MsgError() back upon the first
pulse, the client bump up its’ priority and MsgSend() you again, before
you can process the second pulse…
-xtang
“Xuedong Chen” <> Xuedong.Chen@IGT.com> > wrote in message
news:9n8l6a$7i0$> 1@inn.qnx.com> …
“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:9n8i9m$127$> 1@nntp.qnx.com> …
Xuedong Chen <> Xuedong.Chen@igt.com> > wrote:
Thanks.
- Will OS send an unblock pulse to the Server when the requesting
thread is
being cancelled by pthread_cancel ()?
Yes.
- After the server receives an unblock pulse, how can I set up to
unblock
the requesting thread?
Two main choices: MsgReply() or MsgError().
If your server has not replied to the client, you need to have saved
the client’s rcvid. In the unblock pulse, the pulse.value.sival_int
is the rcvid that corresponds to the client that is trying to be
blocked.
On the server side, you need to either cleanup the unfinished operation
in whatever way makes more sense for the server (roll-back, partial
finish, partial reply, or whatever) and either MsgReply() with
appropriate
results (again, might be partial data, failure notification, etc) or
MsgError(), chosing an appropriate errno value – in this case either
EINTR or ETIMEDOUT are reasonable choices, with EINTR being probably the
best choice.
-David
QNX Training Services
dagibbs@qnx.com