MsgError(), MsgError_r()

Updated: April 19, 2023

Unblock a client and set its error code

Synopsis:

#include <sys/neutrino.h>

int MsgError( int rcvid,
              int error );

int MsgError_r( int rcvid,
                int error );

Arguments:

rcvid
The receive ID that MsgReceive*() returned.
error
-1, ERESTART, EOK, or the error code that you want to set for the client.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The MsgError() and MsgError_r() kernel calls usually unblock the client's MsgSend*() call and set the client's error code to error. No data is transferred.

These functions are identical except in the way they indicate errors. See the Returns section for details.

The error argument determines how the MsgError*() kernel call affects the client's REPLY-blocked MsgSend*() call:

Blocking states

None for the local case. In the network case:

STATE_REPLY
The calling thread is waiting for a network operation to complete. The calling thread is marked as REPLY-blocked on itself (the same process ID as the thread making the call).

Native networking

MsgError() has increased latency when you use it to communicate across a network—the server is now writing the error code to its local lsm-qnet.so, which may need to communicate with the client's lsm-qnet.so to actually transfer the error code.

Returns:

The only difference between these functions is the way they indicate errors:

MsgError()
If an error occurs, this function returns -1 and sets errno. Any other value returned indicates success.
MsgError_r()
If successful, this function returns EOK. This function does NOT set errno, even on success. If an error occurs, it may return any value from the Errors section.

Errors:

ESRCH
The thread indicated by rcvid doesn't exist.
ETIMEDOUT
A kernel timeout unblocked the call. See TimerTimeout().

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes