diff options
author | 2017-10-10 11:18:49 -0700 | |
---|---|---|
committer | 2017-10-12 10:22:48 -0700 | |
commit | 9714e0376a2890b850496c981694af5f91a49353 (patch) | |
tree | afa1e9b7fde0f7884b963b8380cbb07ecfbe136d /include/grpc/impl/codegen/fork.h | |
parent | 70d6041739c45d741e61b7d45762400bed5903a8 (diff) |
Add thread pool reset on fork with FORKING_SUPPORT_ENABLED
Diffstat (limited to 'include/grpc/impl/codegen/fork.h')
-rw-r--r-- | include/grpc/impl/codegen/fork.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/grpc/impl/codegen/fork.h b/include/grpc/impl/codegen/fork.h new file mode 100644 index 0000000000..03c0c4eede --- /dev/null +++ b/include/grpc/impl/codegen/fork.h @@ -0,0 +1,49 @@ +/* + * + * Copyright 2017 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_IMPL_CODEGEN_FORK_H +#define GRPC_IMPL_CODEGEN_FORK_H + +/** + * gRPC applications should call this before calling fork(). There should be no + * active gRPC function calls between calling grpc_prefork() and + * grpc_postfork_parent()/grpc_postfork_child(). + * + * Returns 1 on success, 0 otherwise. + * + * Typical use: + * assert(grpc_prefork() == 1); + * int pid = fork(); + * if (pid) { + * grpc_postfork_parent(); + * // Parent process.. + * } else { + * grpc_postfork_child(); + * // Child process... + * } + */ + +int grpc_prefork(); + +void grpc_postfork_parent(); + +void grpc_postfork_child(); + +void grpc_fork_handlers_auto_register(); + +#endif /* GRPC_IMPL_CODEGEN_FORK_H */ |