1 /* Copyright (c) 2012 Nicira, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 * Thes functions allow an OVS daemon to fork off a "worker process" to do
22 * tasks that may unavoidably block in the kernel. The worker executes remote
23 * procedure calls on behalf of the main process.
25 * Tasks that may unavoidably block in the kernel include writes to regular
26 * files, sends to Generic Netlink sockets (which as of this writing use a
27 * global lock), and other unusual operations.
29 * The worker functions *will* block if the finite buffer between a main
30 * process and its worker process fills up.
40 /* The main process calls this function to start a worker. */
41 void worker_start(void);
43 /* Interface for main process to interact with the worker. */
44 typedef void worker_request_func(struct ofpbuf *request,
45 const int fds[], size_t n_fds);
46 typedef void worker_reply_func(struct ofpbuf *reply,
47 const int fds[], size_t n_fds, void *aux);
49 bool worker_is_running(void);
50 void worker_run(void);
51 void worker_wait(void);
53 void worker_request(const void *data, size_t size,
54 const int fds[], size_t n_fds,
55 worker_request_func *request_cb,
56 worker_reply_func *reply_cb, void *aux);
57 void worker_request_iovec(const struct iovec *iovs, size_t n_iovs,
58 const int fds[], size_t n_fds,
59 worker_request_func *request_cb,
60 worker_reply_func *reply_cb, void *aux);
62 /* Interfaces for RPC implementations (running in the worker process). */
63 void worker_reply(const void *data, size_t size,
64 const int fds[], size_t n_fds);
65 void worker_reply_iovec(const struct iovec *iovs, size_t n_iovs,
66 const int fds[], size_t n_fds);