source: rtems/cpukit/posix/src/mqueuenotify.c @ 3bacb250

4.104.115
Last change on this file since 3bacb250 was feaa007, checked in by Joel Sherrill <joel.sherrill@…>, on 12/17/07 at 16:19:14

2007-12-17 Joel Sherrill <joel.sherrill@…>

  • posix/preinstall.am, posix/include/aio.h, posix/include/devctl.h, posix/include/mqueue.h, posix/include/sched.h, posix/include/semaphore.h, posix/include/rtems/posix/cancel.h, posix/include/rtems/posix/priority.h, posix/include/rtems/posix/psignal.h, posix/include/rtems/posix/threadsup.h, posix/include/rtems/posix/timer.h, posix/inline/rtems/posix/priority.inl, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/cancel.c, posix/src/cancelrun.c, posix/src/cleanuppop.c, posix/src/cleanuppush.c, posix/src/cond.c, posix/src/condattrdestroy.c, posix/src/condattrgetpshared.c, posix/src/condattrinit.c, posix/src/condattrsetpshared.c, posix/src/condbroadcast.c, posix/src/conddefaultattributes.c, posix/src/conddestroy.c, posix/src/condinit.c, posix/src/condsignal.c, posix/src/condsignalsupp.c, posix/src/condwait.c, posix/src/condwaitsupp.c, posix/src/key.c, posix/src/keycreate.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keyrundestructors.c, posix/src/keysetspecific.c, posix/src/mqueue.c, posix/src/mqueueclose.c, posix/src/mqueuecreatesupp.c, posix/src/mqueuedeletesupp.c, posix/src/mqueuegetattr.c, posix/src/mqueuenametoid.c, posix/src/mqueuenotify.c, posix/src/mqueueopen.c, posix/src/mqueuereceive.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesend.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueueunlink.c, posix/src/mutex.c, posix/src/mutexattrdestroy.c, posix/src/mutexattrgetprioceiling.c, posix/src/mutexattrgetprotocol.c, posix/src/mutexattrgetpshared.c, posix/src/mutexattrinit.c, posix/src/mutexattrsetprioceiling.c, posix/src/mutexattrsetprotocol.c, posix/src/mutexattrsetpshared.c, posix/src/mutexdefaultattributes.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexlock.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutextrylock.c, posix/src/mutexunlock.c, posix/src/psignal.c, posix/src/psignalchecksignal.c, posix/src/psignalclearprocesssignals.c, posix/src/psignalclearsignals.c, posix/src/psignalsetprocesssignals.c, posix/src/psignalunblockthread.c, posix/src/ptimer.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c, posix/src/semaphore.c, posix/src/semaphoredeletesupp.c, posix/src/semaphorenametoid.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/seminit.c, posix/src/semopen.c, posix/src/sempost.c, posix/src/semtrywait.c, posix/src/semunlink.c, posix/src/semwait.c, posix/src/setcancelstate.c, posix/src/setcanceltype.c, posix/src/sysconf.c, posix/src/testcancel.c: Add missing copyright statements.
  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  NOTE:  The structure of the routines is identical to that of POSIX
3 *         Message_queues to leave the option of having unnamed message
4 *         queues at a future date.  They are currently not part of the
5 *         POSIX standard but unnamed message_queues are.  This is also
6 *         the reason for the apparently unnecessary tracking of
7 *         the process_shared attribute.  [In addition to the fact that
8 *         it would be trivial to add pshared to the mq_attr structure
9 *         and have process private message queues.]
10 *
11 *         This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open
12 *         time.
13 *
14 *  COPYRIGHT (c) 1989-2007.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.com/license/LICENSE.
20 *
21 *  $Id$
22 */
23
24#if HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include <stdarg.h>
29
30#include <pthread.h>
31#include <limits.h>
32#include <errno.h>
33#include <fcntl.h>
34#include <mqueue.h>
35#include <sys/types.h>
36#include <signal.h>
37
38#include <rtems/system.h>
39#include <rtems/score/watchdog.h>
40#include <rtems/seterr.h>
41#include <rtems/posix/mqueue.h>
42#include <rtems/posix/time.h>
43
44/*PAGE
45 *
46 *  _POSIX_Message_queue_Notify_handler
47 *
48 */
49
50void _POSIX_Message_queue_Notify_handler(
51  void    *user_data
52)
53{
54  POSIX_Message_queue_Control *the_mq;
55
56  the_mq = user_data;
57
58  kill( getpid(), the_mq->notification.sigev_signo );
59
60  _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
61}
62
63/*PAGE
64 *
65 *  15.2.6 Notify Process that a Message is Available on a Queue,
66 *         P1003.1b-1993, p. 280
67 */
68
69int mq_notify(
70  mqd_t                  mqdes,
71  const struct sigevent *notification
72)
73{
74  POSIX_Message_queue_Control    *the_mq;
75  POSIX_Message_queue_Control_fd *the_mq_fd;
76  Objects_Locations               location;
77
78  the_mq_fd = _POSIX_Message_queue_Get_fd( mqdes, &location );
79  switch ( location ) {
80
81    case OBJECTS_LOCAL:
82      the_mq = the_mq_fd->Queue;
83
84      if ( notification ) {
85        if ( _CORE_message_queue_Is_notify_enabled( &the_mq->Message_queue ) ) {
86          _Thread_Enable_dispatch();
87          rtems_set_errno_and_return_minus_one( EBUSY );
88        }
89
90        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
91
92        the_mq->notification = *notification;
93
94        _CORE_message_queue_Set_notify(
95          &the_mq->Message_queue,
96          _POSIX_Message_queue_Notify_handler,
97          the_mq
98        );
99      } else {
100
101        _CORE_message_queue_Set_notify( &the_mq->Message_queue, NULL, NULL );
102
103      }
104
105      _Thread_Enable_dispatch();
106      return 0;
107
108#if defined(RTEMS_MULTIPROCESSING)
109    case OBJECTS_REMOTE:
110#endif
111    case OBJECTS_ERROR:
112      break;
113  }
114
115  rtems_set_errno_and_return_minus_one( EBADF );
116}
Note: See TracBrowser for help on using the repository browser.