Reply to a client with a message, endian-swapping if required
#include <sys/iofunc.h> #include <sys/resmgr.h> int resmgr_msgreply( resmgr_context_t *ctp, void *ptr, size_t len );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The resmgr_msgreply() function replies with a message to the thread identified by ctp->rcvid. It's a wrapper over MsgReplyv() that endian-swaps standard I/O message types for use over Qnet. If Qnet isn't in use, or no endian-swapping is necessary, it simply invokes MsgReplyv(). The resmgr_msgreplyv() function is similar to resmgr_msgreply() but takes an array of message buffers.
Don't use resmgr_msgreply() for delayed replies. This function may modify the contents of the reply buffer based on the info.flags and extra->xendian fields of the ctp structure, before using the rcvid and status fields when calling MsgReplyv(). If you then use this structure in other function calls, you could end up with the wrong endianness when passing data across heterogeneous machines. For delayed replies, you should instead call MsgReply() or MsgReplyv() directly.
You should use resmgr_msgreply() only within the context of an IO handler for the current message.
This function is called by the server to reply back to the client. The client thread must already be in the REPLY state, and the thread being replied to must be in the REPLY-blocked state. Any thread in the receiving process is free to reply to the message; however, it may be replied to only once for each receive.
If the function succeeds, the number of bytes transferred is the minimum of that specified by both the replier and the sender. The reply data isn't allowed to overflow the reply buffer area provided by the sender.
The data transfer occurs immediately, and the replying thread doesn't block. There's no need to reply to received messages in any particular order, but you must eventually reply to each message to allow the sending thread(s) to continue execution.
If an error occurs, -1 is returned and errno is set.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |