source: mainline/uspace/srv/ns/ns.c@ 1be7bee

Last change on this file since 1be7bee was 1be7bee, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

sysman: Move task retval and waiting logic to taskman (partially)

  • two important sessions: NS and taskman
  • depending on boot task vs spawned task those sessions are initiated differently

Conflicts:

uspace/lib/c/generic/async.c
uspace/lib/c/generic/libc.c
uspace/lib/c/generic/task.c
uspace/lib/c/include/ipc/ns.h
uspace/lib/c/include/task.h
uspace/lib/posix/source/sys/wait.c
uspace/srv/loader/main.c
uspace/srv/ns/ns.c

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2006 Ondrej Palkovsky
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 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup ns
30 * @{
31 */
32
33/**
34 * @file ns.c
35 * @brief Naming service for HelenOS IPC.
36 */
37
38#include <abi/ipc/methods.h>
39#include <async.h>
40#include <ipc/ns.h>
41#include <ipc/services.h>
42#include <abi/ipc/interfaces.h>
43#include <stdio.h>
44#include <errno.h>
45#include "ns.h"
46#include "service.h"
47#include "task.h"
48
49static void ns_connection(ipc_call_t *icall, void *arg)
50{
51 ipc_call_t call;
52 iface_t iface;
53 service_t service;
54
55 iface = ipc_get_arg1(icall);
56 service = ipc_get_arg2(icall);
57 if (service != 0) {
58 /*
59 * Client requests to be connected to a service.
60 */
61 ns_service_forward(service, iface, icall);
62 return;
63 }
64
65 async_accept_0(icall);
66
67 while (true) {
68 ns_pending_conn_process();
69
70 async_get_call(&call);
71 if (!ipc_get_imethod(&call))
72 break;
73
74 task_id_t id;
75 errno_t retval;
76
77 service_t service;
78
79 switch (ipc_get_imethod(&call)) {
80 case NS_REGISTER:
81 service = ipc_get_arg1(&call);
82 iface = ipc_get_arg2(&call);
83
84 /*
85 * Server requests service registration.
86 */
87 retval = ns_service_register(service, iface);
88
89 break;
90 case NS_REGISTER_BROKER:
91 service = ipc_get_arg1(&call);
92 retval = ns_service_register_broker(service);
93 break;
94 case NS_PING:
95 retval = EOK;
96 break;
97 case NS_ID_INTRO:
98 retval = ns_task_id_intro(&call);
99 break;
100 default:
101 printf("%s: Method not supported (%" PRIun ")\n",
102 NAME, ipc_get_imethod(&call));
103 retval = ENOTSUP;
104 break;
105 }
106
107 async_answer_0(&call, retval);
108 }
109
110 (void) ns_task_disconnect(&call);
111 async_answer_0(&call, EOK);
112}
113
114int main(int argc, char **argv)
115{
116 printf("%s: HelenOS IPC Naming Service\n", NAME);
117
118 errno_t rc = ns_service_init();
119 if (rc != EOK)
120 return rc;
121
122 rc = task_init();
123 if (rc != EOK)
124 return rc;
125
126 async_set_fallback_port_handler(ns_connection, NULL);
127
128 printf("%s: Accepting connections\n", NAME);
129 async_manager();
130
131 /* Not reached */
132 return 0;
133}
134
135/**
136 * @}
137 */
Note: See TracBrowser for help on using the repository browser.