Browse Source

Merge pull request #1893 from bazingaterry/master

fix an issue and support tcp no-delay in manager mode
pull/1899/head
Max Lv 7 years ago
committed by GitHub
parent
commit
5782a2b5f1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions
  1. 27
      src/manager.c
  2. 2
      src/manager.h

27
src/manager.c

@ -121,6 +121,12 @@ build_config(char *prefix, struct manager_ctx *manager, struct server *server)
fprintf(f, ",\n\"method\":\"%s\"", manager->method);
if (server->fast_open[0])
fprintf(f, ",\n\"fast_open\": %s", server->fast_open);
else if (manager->fast_open)
fprintf(f, ",\n\"fast_open\": true");
if (server->no_delay[0])
fprintf(f, ",\n\"no_delay\": %s", server->no_delay);
else if (manager->no_delay)
fprintf(f, ",\n\"no_delay\": true");
if (server->mode)
fprintf(f, ",\n\"mode\":\"%s\"", server->mode);
if (server->plugin)
@ -182,6 +188,10 @@ construct_command_line(struct manager_ctx *manager, struct server *server)
int len = strlen(cmd);
snprintf(cmd + len, BUF_SIZE - len, " --fast-open");
}
if (server->no_delay[0] == 0 && manager->no_delay) {
int len = strlen(cmd);
snprintf(cmd + len, BUF_SIZE - len, " --no-delay");
}
if (manager->ipv6first) {
int len = strlen(cmd);
snprintf(cmd + len, BUF_SIZE - len, " -6");
@ -294,6 +304,10 @@ get_server(char *buf, int len)
if (value->type == json_boolean) {
strncpy(server->fast_open, (value->u.boolean ? "true" : "false"), 8);
}
} else if (strcmp(name, "no_delay") == 0) {
if (value->type == json_boolean) {
strncpy(server->no_delay, (value->u.boolean ? "true" : "false"), 8);
}
} else if (strcmp(name, "plugin") == 0) {
if (value->type == json_string) {
server->plugin = strdup(value->u.string.ptr);
@ -844,6 +858,7 @@ main(int argc, char **argv)
char *plugin_opts = NULL;
int fast_open = 0;
int no_delay = 0;
int reuse_port = 0;
int mode = TCP_ONLY;
int mtu = 0;
@ -863,6 +878,7 @@ main(int argc, char **argv)
static struct option long_options[] = {
{ "fast-open", no_argument, NULL, GETOPT_VAL_FAST_OPEN },
{ "no-delay", no_argument, NULL, GETOPT_VAL_NODELAY },
{ "reuse-port", no_argument, NULL, GETOPT_VAL_REUSE_PORT },
{ "acl", required_argument, NULL, GETOPT_VAL_ACL },
{ "manager-address", required_argument, NULL,
@ -890,6 +906,9 @@ main(int argc, char **argv)
case GETOPT_VAL_FAST_OPEN:
fast_open = 1;
break;
case GETOPT_VAL_NODELAY:
no_delay = 1;
break;
case GETOPT_VAL_ACL:
acl = optarg;
break;
@ -999,6 +1018,9 @@ main(int argc, char **argv)
if (fast_open == 0) {
fast_open = conf->fast_open;
}
if (no_delay == 0) {
no_delay = conf->no_delay;
}
if (reuse_port == 0) {
reuse_port = conf->reuse_port;
}
@ -1062,6 +1084,10 @@ main(int argc, char **argv)
#endif
}
if (no_delay == 1) {
LOGI("using tcp no-delay");
}
// ignore SIGPIPE
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
@ -1079,6 +1105,7 @@ main(int argc, char **argv)
manager.reuse_port = reuse_port;
manager.fast_open = fast_open;
manager.no_delay = no_delay;
manager.verbose = verbose;
manager.mode = mode;
manager.password = password;

2
src/manager.h

@ -40,6 +40,7 @@ struct manager_ctx {
ev_io io;
int fd;
int fast_open;
int no_delay;
int reuse_port;
int verbose;
int mode;
@ -68,6 +69,7 @@ struct server {
char port[8];
char password[128];
char fast_open[8];
char no_delay[8];
char *mode;
char *method;
char *plugin;

Loading…
Cancel
Save