Deleted Added
full compact
mq.c (156193) mq.c (156267)
1/*-
2 * Copyright (c) 2006 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2006 David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/librt/mq.c 156193 2006-03-01 23:40:00Z davidxu $
26 * $FreeBSD: head/lib/librt/mq.c 156267 2006-03-04 00:18:19Z davidxu $
27 */
28
29#include <sys/cdefs.h>
30#include <sys/types.h>
31#include <sys/syscall.h>
32#include <sys/mqueue.h>
33
34#include "namespace.h"

--- 79 unchanged lines hidden (view full) ---

114 h = mqd->oshandle;
115 free(mqd);
116 return (__sys_close(h));
117}
118
119typedef void (*mq_func)(union sigval val);
120
121static void
27 */
28
29#include <sys/cdefs.h>
30#include <sys/types.h>
31#include <sys/syscall.h>
32#include <sys/mqueue.h>
33
34#include "namespace.h"

--- 79 unchanged lines hidden (view full) ---

114 h = mqd->oshandle;
115 free(mqd);
116 return (__sys_close(h));
117}
118
119typedef void (*mq_func)(union sigval val);
120
121static void
122mq_dispatch(struct sigev_node *sn, siginfo_t *si)
122mq_dispatch(struct sigev_node *sn)
123{
124 mq_func f = sn->sn_func;
125
126 /*
127 * Check generation before calling user function,
128 * this should avoid expired notification.
129 */
123{
124 mq_func f = sn->sn_func;
125
126 /*
127 * Check generation before calling user function,
128 * this should avoid expired notification.
129 */
130 if (sn->sn_gen == si->si_value.sival_int)
130 if (sn->sn_gen == sn->sn_info.si_value.sival_int)
131 f(sn->sn_value);
132}
133
134int
135__mq_notify(mqd_t mqd, const struct sigevent *evp)
136{
137 struct sigevent ev;
138 struct sigev_node *sn;

--- 12 unchanged lines hidden (view full) ---

151 if (__sigev_check_init()) {
152 /*
153 * Thread library is not enabled.
154 */
155 errno = EINVAL;
156 return (-1);
157 }
158
131 f(sn->sn_value);
132}
133
134int
135__mq_notify(mqd_t mqd, const struct sigevent *evp)
136{
137 struct sigevent ev;
138 struct sigev_node *sn;

--- 12 unchanged lines hidden (view full) ---

151 if (__sigev_check_init()) {
152 /*
153 * Thread library is not enabled.
154 */
155 errno = EINVAL;
156 return (-1);
157 }
158
159 sn = __sigev_alloc(SI_MESGQ, evp);
159 sn = __sigev_alloc(SI_MESGQ, evp, mqd->node, 1);
160 if (sn == NULL) {
161 errno = EAGAIN;
162 return (-1);
163 }
164
165 sn->sn_id = mqd->oshandle;
166 sn->sn_dispatch = mq_dispatch;
167 __sigev_get_sigevent(sn, &ev, sn->sn_gen);

--- 67 unchanged lines hidden ---
160 if (sn == NULL) {
161 errno = EAGAIN;
162 return (-1);
163 }
164
165 sn->sn_id = mqd->oshandle;
166 sn->sn_dispatch = mq_dispatch;
167 __sigev_get_sigevent(sn, &ev, sn->sn_gen);

--- 67 unchanged lines hidden ---