0

i would like to know, is there any method to flush all messages which are pipelined on 1 msgQId?????

Pratik
  • 77
  • 1
  • 1
  • 11

1 Answers1

3

There is no built-in API to flush all messages from a message queue.
If all you want to do is discard all messages from a queue, here is a quick way to do this:

void discardQMessages(MSG_Q_ID id) {
  while(
        msgQReceive(id, NULL, 0, NO_WAIT) != ERROR
       )    ;

  if {errno != S_objLib_OBJ_UNAVAILABLE)
     /* Uh oh... got some problem */
}

You should always check errno when you get error from any OS API call.

Benoit
  • 37,894
  • 24
  • 81
  • 116