Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
c7be7c68
Commit
c7be7c68
authored
8 years ago
by
Sree Kuchibhotla
Browse files
Options
Downloads
Patches
Plain Diff
Add an API at the core level to disable signals or use a different
signal number
parent
877dc0cc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpc/grpc_posix.h
+8
-0
8 additions, 0 deletions
include/grpc/grpc_posix.h
src/core/lib/iomgr/ev_epoll_linux.c
+35
-10
35 additions, 10 deletions
src/core/lib/iomgr/ev_epoll_linux.c
with
43 additions
and
10 deletions
include/grpc/grpc_posix.h
+
8
−
0
View file @
c7be7c68
...
@@ -63,6 +63,14 @@ GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
...
@@ -63,6 +63,14 @@ GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
grpc_completion_queue
*
cq
,
grpc_completion_queue
*
cq
,
int
fd
);
int
fd
);
/** GRPC Core POSIX library may internally use signals to optimize some work.
The library uses (SIGRTMIN + 2) signal by default. Use this API to instruct
the library to use a different signal i.e 'signum' instead.
Note:
- To prevent GRPC library from using any signals, pass a 'signum' of -1
- This API is optional but if called, it MUST be called before grpc_init() */
GRPCAPI
void
grpc_use_signal
(
int
signum
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/iomgr/ev_epoll_linux.c
+
35
−
10
View file @
c7be7c68
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
*
*
*/
*/
#include
<grpc/grpc_posix.h>
#include
<grpc/support/port_platform.h>
#include
<grpc/support/port_platform.h>
#ifdef GPR_LINUX_EPOLL
#ifdef GPR_LINUX_EPOLL
...
@@ -58,9 +59,26 @@
...
@@ -58,9 +59,26 @@
#include
"src/core/lib/profiling/timers.h"
#include
"src/core/lib/profiling/timers.h"
#include
"src/core/lib/support/block_annotate.h"
#include
"src/core/lib/support/block_annotate.h"
struct
polling_island
;
static
int
grpc_wakeup_signal
=
-
1
;
static
bool
is_grpc_wakeup_signal_initialized
=
false
;
/* Implements the function defined in grpc_posix.h. This function might be
* called before even calling grpc_init() to set either a different signal to
* use. If signum == -1, then the use of signals is disabled */
void
grpc_use_signal
(
int
signum
)
{
grpc_wakeup_signal
=
signum
;
is_grpc_wakeup_signal_initialized
=
true
;
static
int
grpc_poller_kick_signum
;
if
(
grpc_wakeup_signal
<
0
)
{
gpr_log
(
GPR_INFO
,
"Use of signals is disabled. Epoll engine will not be used"
);
}
else
{
gpr_log
(
GPR_INFO
,
"epoll engine will be using signal: %d"
,
grpc_wakeup_signal
);
}
}
struct
polling_island
;
/*******************************************************************************
/*******************************************************************************
* Fd Declarations
* Fd Declarations
...
@@ -854,10 +872,7 @@ static void sig_handler(int sig_num) {
...
@@ -854,10 +872,7 @@ static void sig_handler(int sig_num) {
#endif
#endif
}
}
static
void
poller_kick_init
()
{
static
void
poller_kick_init
()
{
signal
(
grpc_wakeup_signal
,
sig_handler
);
}
grpc_poller_kick_signum
=
SIGRTMIN
+
2
;
signal
(
grpc_poller_kick_signum
,
sig_handler
);
}
/* Global state management */
/* Global state management */
static
void
pollset_global_init
(
void
)
{
static
void
pollset_global_init
(
void
)
{
...
@@ -874,7 +889,7 @@ static void pollset_global_shutdown(void) {
...
@@ -874,7 +889,7 @@ static void pollset_global_shutdown(void) {
}
}
static
void
pollset_worker_kick
(
grpc_pollset_worker
*
worker
)
{
static
void
pollset_worker_kick
(
grpc_pollset_worker
*
worker
)
{
pthread_kill
(
worker
->
pt_id
,
grpc_
poller_kick
_sign
um
);
pthread_kill
(
worker
->
pt_id
,
grpc_
wakeup
_sign
al
);
}
}
/* Return 1 if the pollset has active threads in pollset_work (pollset must
/* Return 1 if the pollset has active threads in pollset_work (pollset must
...
@@ -1214,9 +1229,9 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
...
@@ -1214,9 +1229,9 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset
->
kicked_without_pollers
=
0
;
pollset
->
kicked_without_pollers
=
0
;
}
else
if
(
!
pollset
->
shutting_down
)
{
}
else
if
(
!
pollset
->
shutting_down
)
{
sigemptyset
(
&
new_mask
);
sigemptyset
(
&
new_mask
);
sigaddset
(
&
new_mask
,
grpc_
poller_kick
_sign
um
);
sigaddset
(
&
new_mask
,
grpc_
wakeup
_sign
al
);
pthread_sigmask
(
SIG_BLOCK
,
&
new_mask
,
&
orig_mask
);
pthread_sigmask
(
SIG_BLOCK
,
&
new_mask
,
&
orig_mask
);
sigdelset
(
&
orig_mask
,
grpc_
poller_kick
_sign
um
);
sigdelset
(
&
orig_mask
,
grpc_
wakeup
_sign
al
);
push_front_worker
(
pollset
,
&
worker
);
push_front_worker
(
pollset
,
&
worker
);
...
@@ -1497,19 +1512,29 @@ static bool is_epoll_available() {
...
@@ -1497,19 +1512,29 @@ static bool is_epoll_available() {
}
}
const
grpc_event_engine_vtable
*
grpc_init_epoll_linux
(
void
)
{
const
grpc_event_engine_vtable
*
grpc_init_epoll_linux
(
void
)
{
/* If use of signals is disabled, we cannot use epoll engine*/
if
(
is_grpc_wakeup_signal_initialized
&&
grpc_wakeup_signal
<
0
)
{
return
NULL
;
}
if
(
!
is_epoll_available
())
{
if
(
!
is_epoll_available
())
{
return
NULL
;
return
NULL
;
}
}
if
(
!
is_grpc_wakeup_signal_initialized
)
{
grpc_use_signal
(
SIGRTMIN
+
2
);
}
fd_global_init
();
fd_global_init
();
pollset_global_init
();
pollset_global_init
();
polling_island_global_init
();
polling_island_global_init
();
return
&
vtable
;
return
&
vtable
;
}
}
#else
/* defined(GPR_LINUX_EPOLL) */
#else
/* defined(GPR_LINUX_EPOLL) */
/* If GPR_LINUX_EPOLL is not defined, it means epoll is not available. Return
/* If GPR_LINUX_EPOLL is not defined, it means epoll is not available. Return
* NULL */
* NULL */
const
grpc_event_engine_vtable
*
grpc_init_epoll_linux
(
void
)
{
return
NULL
;
}
const
grpc_event_engine_vtable
*
grpc_init_epoll_linux
(
void
)
{
return
NULL
;
}
void
grpc_use_signal
(
int
signum
)
{}
#endif
/* !defined(GPR_LINUX_EPOLL) */
#endif
/* !defined(GPR_LINUX_EPOLL) */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment