"Fossies" - the Fresh Open Source Software Archive 
Member "httperf-0.9.0/src/gen/conn_rate.c" (7 Apr 2007, 2689 Bytes) of package /linux/www/old/httperf-0.9.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "conn_rate.c" see the
Fossies "Dox" file reference documentation.
1 /*
2 httperf -- a tool for measuring web server performance
3 Copyright 2000-2007 Hewlett-Packard Company and Contributors listed in
4 AUTHORS file. Originally contributed by David Mosberger-Tang
5
6 This file is part of httperf, a web server performance measurment
7 tool.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
13
14 In addition, as a special exception, the copyright holders give
15 permission to link the code of this work with the OpenSSL project's
16 "OpenSSL" library (or with modified versions of it that use the same
17 license as the "OpenSSL" library), and distribute linked combinations
18 including the two. You must obey the GNU General Public License in
19 all respects for all of the code used other than "OpenSSL". If you
20 modify this file, you may extend this exception to your version of the
21 file, but you are not obligated to do so. If you do not wish to do
22 so, delete this exception statement from your version.
23
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with this program; if not, write to the Free Software
31 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 02110-1301, USA
33 */
34
35 /* Creates connections at the fixed rate PARAM.RATE or sequentially if
36 PARAM.RATE is zero. */
37
38 #include <assert.h>
39 #include <stdio.h>
40
41 #include <httperf.h>
42 #include <core.h>
43 #include <event.h>
44 #include <rate.h>
45 #include <conn.h>
46 #include <timer.h>
47
48 static int num_conns_generated;
49 static int num_conns_destroyed;
50 static Rate_Generator rg;
51
52 static int
53 make_conn (Any_Type arg)
54 {
55 Conn *s;
56
57 if (num_conns_generated++ >= param.num_conns)
58 return -1;
59
60 s = conn_new ();
61 if (!s)
62 return -1;
63
64 core_connect (s);
65 return 0;
66 }
67
68 static void
69 destroyed (void)
70 {
71 if (++num_conns_destroyed >= param.num_conns)
72 core_exit ();
73 }
74
75 static void
76 init (void)
77 {
78 Any_Type arg;
79
80 rg.arg.l = 0;
81 rg.tick = make_conn;
82
83 arg.l = 0;
84 event_register_handler (EV_CONN_DESTROYED, (Event_Handler) destroyed, arg);
85 }
86
87 static void
88 start (void)
89 {
90 rg.rate = ¶m.rate;
91 rate_generator_start (&rg, EV_CONN_DESTROYED);
92 }
93
94 Load_Generator conn_rate =
95 {
96 "creates connections at a fixed rate",
97 init,
98 start,
99 no_op
100 };