]>
sourceware.org Git - newlib-cygwin.git/blob - winsup/cygserver/msg.cc
1 /* msg.cc: Single unix specification IPC interface for Cygwin.
3 Copyright 2003, 2004 Red Hat, Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 #ifdef __OUTSIDE_CYGWIN__
21 #include "cygserver.h"
23 #include "transport.h"
25 #include "cygserver_ipc.h"
26 #include "cygserver_msg.h"
28 client_request_msg::client_request_msg ()
29 : client_request (CYGSERVER_REQUEST_MSG
,
30 &_parameters
, sizeof (_parameters
))
35 client_request_msg::serve (transport_layer_base
*const conn
,
36 process_cache
*const cache
)
38 if (msglen () != sizeof (_parameters
.in
))
40 syscall_printf ("bad request body length: expecting %lu bytes, got %lu",
41 sizeof (_parameters
), msglen ());
46 if (support_msgqueues
== TUN_FALSE
)
48 syscall_printf ("Message queue support not started");
50 if (_parameters
.in
.msgop
== MSGOP_msgrcv
)
51 _parameters
.out
.rcv
= -1;
53 _parameters
.out
.ret
= -1;
54 msglen (sizeof (_parameters
.out
));
57 process
*const client
= cache
->process (_parameters
.in
.ipcblk
.cygpid
,
58 _parameters
.in
.ipcblk
.winpid
,
59 _parameters
.in
.ipcblk
.signal_arrived
);
66 if (!conn
->impersonate_client ())
73 if (!adjust_identity_info (&_parameters
.in
.ipcblk
))
76 conn
->revert_to_self ();
81 /* Early revert_to_self since IPC code runs in kernel mode. */
82 conn
->revert_to_self ();
83 /* sysv_msg.cc takes care of itself. */
85 thread td
= { client
, &_parameters
.in
.ipcblk
, {-1, -1} };
87 msgop_t msgop
= _parameters
.in
.msgop
; /* Get's overwritten otherwise. */
91 res
= msgctl (&td
, &_parameters
.in
.ctlargs
);
94 res
= msgget (&td
, &_parameters
.in
.getargs
);
97 res
= msgrcv (&td
, &_parameters
.in
.rcvargs
);
100 res
= msgsnd (&td
, &_parameters
.in
.sndargs
);
104 td
.td_retval
[0] = -1;
107 /* Allocated by the call to adjust_identity_info(). */
108 if (_parameters
.in
.ipcblk
.gidlist
)
109 free (_parameters
.in
.ipcblk
.gidlist
);
111 if (msgop
== MSGOP_msgrcv
)
112 _parameters
.out
.rcv
= td
.td_retval
[0];
114 _parameters
.out
.ret
= td
.td_retval
[0];
115 msglen (sizeof (_parameters
.out
));
117 #endif /* __OUTSIDE_CYGWIN__ */
This page took 0.043675 seconds and 5 git commands to generate.