forked from google/neper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcp_crr.c
43 lines (39 loc) · 1.38 KB
/
tcp_crr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright 2016 Google Inc.
*
* 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.
*/
#include "common.h"
#include "rr.h"
#include "socket.h"
#include "thread.h"
static const struct neper_fn client_fn = {
.fn_loop_init = socket_connect_all,
.fn_flow_init = crr_flow_init,
.fn_report = rr_report_stats,
.fn_type = SOCK_STREAM
};
static const struct neper_fn server_fn = {
.fn_loop_init = socket_listen,
.fn_flow_init = crr_flow_init,
.fn_report = rr_report_stats,
.fn_type = SOCK_STREAM
};
int tcp_crr(struct options *opts, struct callbacks *cb)
{
const struct neper_fn *fn = opts->client ? &client_fn : &server_fn;
/* tcp_crr server doesn't collect stats, as it uses too much memory. */
if (!opts->client)
opts->nostats = true;
return run_main_thread(opts, cb, fn);
}