Skip to content

Commit

Permalink
修改命名
Browse files Browse the repository at this point in the history
  • Loading branch information
bg5sbk committed Jan 6, 2016
1 parent 50ceca8 commit 97f0885
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions linux/gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ const char *HS_DIAL_ERR = "500"; // can't connect to backend
const char *HS_DIAL_TIMEOUT = "504"; // connect to backend timeout

// catch SIGTERM
int gw_stop = 0;
void interrupt(int signal_id)
{
gw_stop = 1;
int gw_stop_flag = 0;
void gw_stop(int signal_id) {
gw_stop_flag = 1;
}

// handshake state
Expand Down Expand Up @@ -427,7 +426,7 @@ gw_loop(int pd, int lsn, char *secret) {
for (;;) {
int rc = epoll_wait(pd, readys, MAX_EVENTS, -1);
if (rc < 0) {
if (errno == EINTR && !gw_stop) {
if (errno == EINTR && !gw_stop_flag) {
continue;
}
break;
Expand Down Expand Up @@ -569,7 +568,7 @@ main(int argc, char *argv[]) {
// catch SIGTERM
struct sigaction sa;
memset(&sa, 0, sizeof(struct sigaction *));
sa.sa_handler = interrupt;
sa.sa_handler = gw_stop;
sa.sa_flags = 0;
sigemptyset (&(sa.sa_mask));
if (sigaction(SIGTERM, &sa, NULL) != 0) {
Expand Down

0 comments on commit 97f0885

Please sign in to comment.