Browse Source

Add concurrency limit for the client.

tags/0.7.0
Vsevolod Stakhov 10 years ago
parent
commit
7f9bff354f
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/client/rspamc.c

+ 9
- 1
src/client/rspamc.c View File

static gchar *local_addr = NULL; static gchar *local_addr = NULL;
static gint weight = 1; static gint weight = 1;
static gint flag; static gint flag;
static gint max_requests = 1024;
static gdouble timeout = 5.0; static gdouble timeout = 5.0;
static gboolean pass_all; static gboolean pass_all;
static gboolean tty = FALSE; static gboolean tty = FALSE;
{ "json", 'j', 0, G_OPTION_ARG_NONE, &json, "Output json reply", NULL }, { "json", 'j', 0, G_OPTION_ARG_NONE, &json, "Output json reply", NULL },
{ "headers", 0, 0, G_OPTION_ARG_NONE, &headers, "Output HTTP headers", NULL }, { "headers", 0, 0, G_OPTION_ARG_NONE, &headers, "Output HTTP headers", NULL },
{ "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "Output raw reply from rspamd", NULL }, { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "Output raw reply from rspamd", NULL },
{ "max-requests", 'n', 0, G_OPTION_ARG_INT, &max_requests, "Maximum count of parallel requests to rspamd", NULL },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
}; };


gint gint
main (gint argc, gchar **argv, gchar **env) main (gint argc, gchar **argv, gchar **env)
{ {
gint i, start_argc;
gint i, start_argc, cur_req = 0;
GHashTable *kwattrs; GHashTable *kwattrs;
struct rspamc_command *cmd; struct rspamc_command *cmd;
FILE *in = NULL; FILE *in = NULL;
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
rspamc_process_input (ev_base, cmd, in, argv[i], kwattrs); rspamc_process_input (ev_base, cmd, in, argv[i], kwattrs);
cur_req ++;
fclose (in); fclose (in);
if (cur_req >= max_requests) {
cur_req = 0;
/* Wait for completion */
event_base_loop (ev_base, 0);
}
} }
} }



Loading…
Cancel
Save