├── .cproject
├── .gitignore
├── .project
├── .settings
├── .svn
│ ├── all-wcprops
│ ├── entries
│ ├── prop-base
│ │ └── org.eclipse.cdt.ui.prefs.svn-base
│ └── text-base
│ │ ├── org.eclipse.cdt.codan.core.prefs.svn-base
│ │ └── org.eclipse.cdt.ui.prefs.svn-base
├── org.eclipse.cdt.codan.core.prefs
└── org.eclipse.cdt.ui.prefs
├── Makefile
├── README.md
├── doc
├── CTS_libevent.pdf
├── command.plist
├── constant hash.jpg
└── gingko.1
├── lib
├── libev
├── libev-4.04.tar.gz
├── libev_auxten.patch
└── patch_build.sh
├── src
├── AUTHORS
├── ChangeLog
├── Makefile.am
├── NEWS
├── README
├── TODO
├── async_conn.cpp
├── async_pool.h
├── async_threads.cpp
├── autogen.sh
├── clnt_main.cpp
├── clnt_unittest.cpp
├── configure.in
├── erase_job.py
├── gingko.h
├── gingko_base.cpp
├── gingko_clnt.cpp
├── gingko_clnt.h
├── gingko_common.h
├── gingko_serv.cpp
├── gingko_serv.h
├── hash
│ ├── AUTHORS
│ ├── ChangeLog
│ ├── Makefile.am
│ ├── NEWS
│ ├── README
│ ├── configure.in
│ ├── gko_zip.cpp
│ ├── gko_zip.h
│ ├── lz4.cpp
│ ├── lz4.h
│ ├── md5.cpp
│ ├── md5.h
│ ├── xor_hash.cpp
│ └── xor_hash.h
├── install-sh
├── job_state.h
├── limit.cpp
├── limit.h
├── log.cpp
├── log.h
├── missing
├── option.cpp
├── option.h
├── path.cpp
├── path.h
├── progress.cpp
├── progress.h
├── route.cpp
├── route.h
├── run.sh
├── run2.sh
├── seed.cpp
├── seed.h
├── serv_main.cpp
├── serv_unittest.cpp
├── snap.cpp
├── snap.h
├── socket.cpp
├── socket.h
└── unittest.h
└── testcase
├── test.sh
├── test.sh.absln
└── test.sh.ln
/.cproject:
--------------------------------------------------------------------------------
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 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | INSTALL
2 | depcomp
3 | Makefile.in
4 | COPYING
5 | aclocal.m4
6 | bin/
7 | conf/
8 | deploy
9 | src/p2p.sh
10 | src/p2pcheck.sh
11 | configure
12 | svn-commit.*
13 | .deps/
14 | clnt_unittest
15 | serv_unittest
16 | config.h.in
17 | config.h
18 | config.log
19 | config.status
20 | *.tar.gz
21 | src/hash/Makefile
22 | src/Makefile
23 | *.dmg
24 | .DS_Store
25 | autom4te*
26 | gingko_clnt
27 | gingko_serv
28 | stamp-h1
29 | *.orig
30 | kfp_docs*
31 | server.log
32 | client.log
33 | *.[ao]
34 | build/
35 | *~
36 | .svn/
37 | test
38 | output*
39 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | gingko
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 | ?name?
14 |
15 |
16 |
17 | org.eclipse.cdt.make.core.append_environment
18 | true
19 |
20 |
21 | org.eclipse.cdt.make.core.autoBuildTarget
22 | all
23 |
24 |
25 | org.eclipse.cdt.make.core.buildArguments
26 |
27 |
28 |
29 | org.eclipse.cdt.make.core.buildCommand
30 | make
31 |
32 |
33 | org.eclipse.cdt.make.core.cleanBuildTarget
34 | clean
35 |
36 |
37 | org.eclipse.cdt.make.core.contents
38 | org.eclipse.cdt.make.core.activeConfigSettings
39 |
40 |
41 | org.eclipse.cdt.make.core.enableAutoBuild
42 | false
43 |
44 |
45 | org.eclipse.cdt.make.core.enableCleanBuild
46 | true
47 |
48 |
49 | org.eclipse.cdt.make.core.enableFullBuild
50 | true
51 |
52 |
53 | org.eclipse.cdt.make.core.fullBuildTarget
54 | all
55 |
56 |
57 | org.eclipse.cdt.make.core.stopOnError
58 | true
59 |
60 |
61 | org.eclipse.cdt.make.core.useDefaultBuildCmd
62 | true
63 |
64 |
65 |
66 |
67 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
68 | full,incremental,
69 |
70 |
71 |
72 |
73 |
74 | org.eclipse.cdt.core.cnature
75 | org.eclipse.cdt.core.ccnature
76 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
77 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
78 |
79 |
80 |
--------------------------------------------------------------------------------
/.settings/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 57
4 | /op/oped/noah/!svn/ver/60093/trunk/tools/gingko/.settings
5 | END
6 | org.eclipse.cdt.codan.core.prefs
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 90
10 | /op/oped/noah/!svn/ver/60093/trunk/tools/gingko/.settings/org.eclipse.cdt.codan.core.prefs
11 | END
12 | org.eclipse.cdt.ui.prefs
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 82
16 | /op/oped/noah/!svn/ver/45469/trunk/tools/gingko/.settings/org.eclipse.cdt.ui.prefs
17 | END
18 |
--------------------------------------------------------------------------------
/.settings/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 69182
5 | https://svn.baidu.com/op/oped/noah/trunk/tools/gingko/.settings
6 | https://svn.baidu.com/op/oped/noah
7 |
8 |
9 |
10 | 2011-08-08T08:43:59.747744Z
11 | 60093
12 | wangpengcheng01
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 50f7a8e2-900c-44df-8b5b-4a1fb65e17d8
28 |
29 | org.eclipse.cdt.codan.core.prefs
30 | file
31 |
32 |
33 |
34 |
35 | 2011-08-08T08:47:30.000000Z
36 | 740a5af795b70b0e0452c0719ac2a6af
37 | 2011-08-08T08:43:59.747744Z
38 | 60093
39 | wangpengcheng01
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 6578
62 |
63 | org.eclipse.cdt.ui.prefs
64 | file
65 |
66 |
67 |
68 |
69 | 2011-08-08T08:47:30.000000Z
70 | f446829872c7b49963aebc05b90cbb6c
71 | 2011-06-05T05:25:24.151365Z
72 | 45469
73 | wangpengcheng01
74 | has-props
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 89
96 |
97 |
--------------------------------------------------------------------------------
/.settings/.svn/prop-base/org.eclipse.cdt.ui.prefs.svn-base:
--------------------------------------------------------------------------------
1 | K 13
2 | svn:mime-type
3 | V 10
4 | text/plain
5 | END
6 |
--------------------------------------------------------------------------------
/.settings/.svn/text-base/org.eclipse.cdt.codan.core.prefs.svn-base:
--------------------------------------------------------------------------------
1 | #Mon Aug 08 10:39:20 CST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning
4 | org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
5 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error
6 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
7 | org.eclipse.cdt.codan.checkers.noreturn=Error
8 | org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
10 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
12 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
14 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={}
15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
16 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
18 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
20 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
22 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
23 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
25 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
27 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
29 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
31 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
33 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
35 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
37 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=Info
38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
39 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={}
41 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
43 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
45 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
47 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=Warning
48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={}
49 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=Warning
50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={}
51 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()}
53 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
55 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
57 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
59 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
61 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
63 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
65 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
67 |
--------------------------------------------------------------------------------
/.settings/.svn/text-base/org.eclipse.cdt.ui.prefs.svn-base:
--------------------------------------------------------------------------------
1 | #Sun Jun 05 13:16:25 CST 2011
2 | eclipse.preferences.version=1
3 | formatter_settings_version=1
4 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.codan.core.prefs:
--------------------------------------------------------------------------------
1 | #Mon Aug 08 10:39:20 CST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning
4 | org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
5 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error
6 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
7 | org.eclipse.cdt.codan.checkers.noreturn=Error
8 | org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
10 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
12 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
14 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={}
15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
16 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
18 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
20 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
22 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
23 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
25 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
27 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
29 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
31 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
33 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
35 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
37 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=Info
38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
39 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={}
41 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
43 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
45 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
47 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=Warning
48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={}
49 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=Warning
50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={}
51 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()}
53 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
55 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
57 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
59 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
61 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
63 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
65 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
67 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.cdt.ui.prefs:
--------------------------------------------------------------------------------
1 | #Sun Jun 05 13:16:25 CST 2011
2 | eclipse.preferences.version=1
3 | formatter_settings_version=1
4 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: all makelib compile rm_config clean move check
2 | all: check_configure makelib compile #move rm_config
3 |
4 | check_configure:
5 | if [ ! -x ./src/configure ]; then ( cd ./src && ./autogen.sh ); fi
6 |
7 | makelib:
8 | cd lib && bash -x patch_build.sh && cd ..
9 |
10 | compile:
11 | #cd src && ./configure CXXFLAGS='-ggdb -D_GKO_VERSION=\"$(subst VERSION:,,$(VERSION_SCMPF))\"' --enable-debug -enable-unittest && make clean &&
12 | cd src && ./configure CXXFLAGS='-ggdb ' --enable-debug && make clean && \
13 | cd hash && make && cd .. && make -j 4 && cd ..
14 |
15 | rm_config:
16 | rm ./src/config.h
17 | rm ./src/hash/config.h
18 | rm -rf ./lib/libev/include
19 |
20 | clean:
21 | pwd
22 | rm -rf output test
23 | cd src && if [ -f Makefile ];then make clean; fi
24 | #find ./../../../../../../.. -type f -name "event.h"
25 |
26 | move:
27 | if [ ! -d output ];then mkdir output;fi
28 | cd output && if [ ! -d bin ];then mkdir bin; fi && \
29 | if [ ! -d testbin ];then mkdir testbin; fi && \
30 | if [ ! -d conf ];then mkdir conf; fi
31 | cp ./src/gingko_serv ./output/bin/gkod
32 | cp ./src/gingko_clnt ./output/bin/gkocp
33 | cp ./src/serv_unittest ./output/testbin/
34 | cp ./src/clnt_unittest ./output/testbin/
35 | cp -r ./output/testbin ./test
36 | cp ./bin/* ./output/bin/
37 | cp ./conf/* ./output/conf/
38 | #cp ./src/erase_job.py ./output/bin/
39 | #cp ./src/run2.sh ./output/bin/gkod_ctl
40 | cp deploy ./output/ && chmod +x ./output/deploy
41 | cd output && md5sum deploy bin/* conf/* > md5sum
42 | #cd output/bin && cp gkocp{,.new}
43 | #cd output/bin && cp gkod{,.new}
44 | #cd output/bin && cp gkod_ctl{,.new}
45 | chmod +x ./output/bin/*
46 | cd output && tar czvf gingko.tgz bin conf md5sum deploy
47 |
48 | check:
49 | cd test && ./clnt_unittest && ./serv_unittest
50 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | src/README
--------------------------------------------------------------------------------
/doc/CTS_libevent.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/auxten/gingko/ceeeaaa9bb4ee7e6cde43f45f80f4e7c71f97ff2/doc/CTS_libevent.pdf
--------------------------------------------------------------------------------
/doc/command.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | GET
6 |
7 | Description
8 | client请求blocks
9 | Command
10 | GET block_id
11 | Function
12 | int get_blocks(long block_id, int job_id)
13 |
14 | QUIT
15 |
16 | Description
17 | client退出job
18 | Command
19 | QUIT job_id
20 | Function
21 | int quit_job(int job_id)
22 |
23 | JOIN
24 |
25 | Description
26 | client加入job
27 | Command
28 | JOIN uri
29 | Function
30 | int join_job(char * uri)
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/doc/constant hash.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/auxten/gingko/ceeeaaa9bb4ee7e6cde43f45f80f4e7c71f97ff2/doc/constant hash.jpg
--------------------------------------------------------------------------------
/doc/gingko.1:
--------------------------------------------------------------------------------
1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
2 | .\"See Also:
3 | .\"man mdoc.samples for a complete listing of options
4 | .\"man mdoc for the short list of editing options
5 | .\"/usr/share/misc/mdoc.template
6 | .Dd 11-3-31 \" DATE
7 | .Dt gingko 1 \" Program name and manual section number
8 | .Os Darwin
9 | .Sh NAME \" Section Header - required - don't modify
10 | .Nm gingko,
11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key
12 | .\" words here as the database is built based on the words here and in the .ND line.
13 | .Nm Other_name_for_same_program(),
14 | .Nm Yet another name for the same program.
15 | .\" Use .Nm macro to designate other names for the documented program.
16 | .Nd This line parsed for whatis database.
17 | .Sh SYNOPSIS \" Section Header - required - don't modify
18 | .Nm
19 | .Op Fl abcd \" [-abcd]
20 | .Op Fl a Ar path \" [-a path]
21 | .Op Ar file \" [file]
22 | .Op Ar \" [file ...]
23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline
24 | arg2 ... \" Arguments
25 | .Sh DESCRIPTION \" Section Header - required - don't modify
26 | Use the .Nm macro to refer to your program throughout the man page like such:
27 | .Nm
28 | Underlining is accomplished with the .Ar macro like this:
29 | .Ar underlined text .
30 | .Pp \" Inserts a space
31 | A list of items with descriptions:
32 | .Bl -tag -width -indent \" Begins a tagged list
33 | .It item a \" Each item preceded by .It macro
34 | Description of item a
35 | .It item b
36 | Description of item b
37 | .El \" Ends the list
38 | .Pp
39 | A list of flags and their descriptions:
40 | .Bl -tag -width -indent \" Differs from above in tag removed
41 | .It Fl a \"-a flag as a list item
42 | Description of -a flag
43 | .It Fl b
44 | Description of -b flag
45 | .El \" Ends the list
46 | .Pp
47 | .\" .Sh ENVIRONMENT \" May not be needed
48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
49 | .\" .It Ev ENV_VAR_1
50 | .\" Description of ENV_VAR_1
51 | .\" .It Ev ENV_VAR_2
52 | .\" Description of ENV_VAR_2
53 | .\" .El
54 | .Sh FILES \" File used or created by the topic of the man page
55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
56 | .It Pa /usr/share/file_name
57 | FILE_1 description
58 | .It Pa /Users/joeuser/Library/really_long_file_name
59 | FILE_2 description
60 | .El \" Ends the list
61 | .\" .Sh DIAGNOSTICS \" May not be needed
62 | .\" .Bl -diag
63 | .\" .It Diagnostic Tag
64 | .\" Diagnostic informtion here.
65 | .\" .It Diagnostic Tag
66 | .\" Diagnostic informtion here.
67 | .\" .El
68 | .Sh SEE ALSO
69 | .\" List links in ascending order by section, alphabetically within a section.
70 | .\" Please do not reference files that do not exist without filing a bug report
71 | .Xr a 1 ,
72 | .Xr b 1 ,
73 | .Xr c 1 ,
74 | .Xr a 2 ,
75 | .Xr b 2 ,
76 | .Xr a 3 ,
77 | .Xr b 3
78 | .\" .Sh BUGS \" Document known, unremedied bugs
79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner
--------------------------------------------------------------------------------
/lib/libev:
--------------------------------------------------------------------------------
1 | libev-4.04fixed
--------------------------------------------------------------------------------
/lib/libev-4.04.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/auxten/gingko/ceeeaaa9bb4ee7e6cde43f45f80f4e7c71f97ff2/lib/libev-4.04.tar.gz
--------------------------------------------------------------------------------
/lib/libev_auxten.patch:
--------------------------------------------------------------------------------
1 | diff -upNr libev-4.04/ev.c libev-4.04-fixed/ev.c
2 | --- libev-4.04/ev.c 2011-02-09 07:17:37.000000000 +0800
3 | +++ libev-4.04-fixed/ev.c 2011-09-07 15:29:55.000000000 +0800
4 | @@ -948,6 +948,8 @@ fd_event_nocheck (EV_P_ int fd, int reve
5 |
6 | if (ev)
7 | ev_feed_event (EV_A_ (W)w, ev);
8 | + if (w == (ev_io *)((WL)w)->next)
9 | + break;
10 | }
11 | }
12 |
13 | @@ -1017,7 +1019,11 @@ fd_reify (EV_P)
14 | anfd->events = 0;
15 |
16 | for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
17 | - anfd->events |= (unsigned char)w->events;
18 | + {
19 | + anfd->events |= (unsigned char)w->events;
20 | + if (w == (ev_io *)((WL)w)->next)
21 | + break;
22 | + }
23 |
24 | if (o_events != anfd->events)
25 | o_reify = EV__IOFDSET; /* actually |= */
26 | @@ -1495,6 +1501,8 @@ child_reap (EV_P_ int chain, int pid, in
27 | w->rstatus = status;
28 | ev_feed_event (EV_A_ (W)w, EV_CHILD);
29 | }
30 | + if (w == (ev_child *)((WL)w)->next)
31 | + break;
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/lib/patch_build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #/bin/sh
4 |
5 | #specify where to install by PREFIX or COMMAND-LINE ARG1
6 | PREFIX="$PWD/libev-4.04fixed"
7 | if [ -n "$1" ]; then
8 | PREFIX=$1
9 | fi
10 | SRCDIR=libev-4.04
11 | LIBNAME="libev-4.04"
12 | if [ -d "$SRCDIR" ]; then
13 | rm -rf $SRCDIR
14 | fi
15 | file=$LIBNAME.tar.gz
16 | if [ ! -f "$file" ]; then
17 | echo "error: no $file"
18 | exit 1
19 | fi
20 | tar xvzf $file
21 | if [ ! -d "$SRCDIR" ]; then
22 | echo "error: no $SRCDIR"
23 | exit 1
24 | fi
25 |
26 | cp libev_auxten.patch $SRCDIR/libev_auxten.patch
27 | cd $SRCDIR
28 | patch -p1 < libev_auxten.patch
29 |
30 | ./configure --prefix=$PREFIX --enable-shared=no --enable-static
31 |
32 | make; make install
33 | cd ..
34 |
35 | rm -rf libev
36 | ln -s libev-4.04fixed libev
37 | rm -rf $SRCDIR
38 |
39 | echo "done!"
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/AUTHORS:
--------------------------------------------------------------------------------
1 | auxtenwpc@gmail.com
2 |
--------------------------------------------------------------------------------
/src/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/auxten/gingko/ceeeaaa9bb4ee7e6cde43f45f80f4e7c71f97ff2/src/ChangeLog
--------------------------------------------------------------------------------
/src/Makefile.am:
--------------------------------------------------------------------------------
1 | SUBDIRS = hash .
2 | INCLUDES = -I$(srcdir)/src\
3 | -I$(srcdir)/hash \
4 | -include config.h \
5 | -I$(srcdir)/../lib/libev/include
6 | # -I$(srcdir)/../../../../../../third-64/libev/include
7 | # -I$(srcdir)/../../../../../../../third-64/libev/include
8 | #export INCLUDES
9 |
10 | noinst_PROGRAMS=gingko_serv gingko_clnt
11 |
12 | clnt_unittest_SOURCES=async_threads.cpp async_conn.cpp \
13 | gingko_base.cpp path.cpp log.cpp option.cpp socket.cpp limit.cpp \
14 | route.cpp snap.cpp clnt_unittest.cpp gingko_clnt.cpp progress.cpp
15 | clnt_unittest_LDADD=$(srcdir)/../lib/libev/lib/libev.a \
16 | $(srcdir)/../../../../../../third-64/gtest/lib/libgtest.a \
17 | $(srcdir)/hash/libxor_hash.a \
18 | $(srcdir)/hash/libgko_zip.a
19 | clnt_unittest_LDFLAGS=-D_GNU_SOURCE -ggdb -funsigned-char
20 |
21 | serv_unittest_SOURCES=async_threads.cpp async_conn.cpp \
22 | gingko_base.cpp path.cpp log.cpp option.cpp socket.cpp limit.cpp \
23 | seed.cpp hash/xor_hash.cpp serv_unittest.cpp gingko_serv.cpp
24 | serv_unittest_LDADD=$(srcdir)/../lib/libev/lib/libev.a \
25 | $(srcdir)/../../../../../../third-64/gtest/lib/libgtest.a \
26 | $(srcdir)/hash/libxor_hash.a \
27 | $(srcdir)/hash/libgko_zip.a
28 | serv_unittest_LDFLAGS=-D_GNU_SOURCE -ggdb -funsigned-char
29 |
30 | gingko_serv_SOURCES=async_threads.cpp async_conn.cpp gingko_serv.cpp serv_main.cpp\
31 | gingko_base.cpp path.cpp log.cpp option.cpp socket.cpp limit.cpp \
32 | seed.cpp
33 | gingko_serv_LDADD=$(srcdir)/../lib/libev/lib/libev.a \
34 | $(srcdir)/hash/libxor_hash.a \
35 | $(srcdir)/hash/libgko_zip.a
36 | gingko_serv_LDFLAGS=-D_GNU_SOURCE -ggdb -funsigned-char -lpthread
37 |
38 | gingko_clnt_SOURCES=async_threads.cpp async_conn.cpp gingko_clnt.cpp clnt_main.cpp\
39 | gingko_base.cpp path.cpp log.cpp option.cpp socket.cpp limit.cpp \
40 | route.cpp snap.cpp progress.cpp
41 | gingko_clnt_LDADD=$(srcdir)/../lib/libev/lib/libev.a \
42 | $(srcdir)/hash/libxor_hash.a \
43 | $(srcdir)/hash/libgko_zip.a
44 | gingko_clnt_LDFLAGS=-D_GNU_SOURCE -ggdb -funsigned-char -lpthread
45 |
46 | DEFS=-D_GNU_SOURCE -ggdb -funsigned-char
47 |
--------------------------------------------------------------------------------
/src/NEWS:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/auxten/gingko/ceeeaaa9bb4ee7e6cde43f45f80f4e7c71f97ff2/src/NEWS
--------------------------------------------------------------------------------
/src/README:
--------------------------------------------------------------------------------
1 | SEE: http://auxten.github.io/gingko/
2 |
--------------------------------------------------------------------------------
/src/TODO:
--------------------------------------------------------------------------------
1 | 线程池可以扩大
2 | 线程缓冲区做成缓冲池
3 | # client的ip以及port getpeername inet_ntoa
4 | # zero file core
5 | # sendfile BSD linux不太相同 可以考虑采用mmap + write See: http://blog.sina.com.cn/s/blog_4967ea190100ja5p.html
6 | # find port to listen
7 | # strerror strerror_r必要?
8 | # 跨文件的数据块校验失败
9 | # libevent读文件event_init event_base_del效率低 也许select更好 增大块大小可以缓解
10 | # 多线程xor_hash
11 | # shutdown socket
12 | # socket 超时
13 | # 最后请求server
14 | # vnode 使用线程
15 | # sendblock broken pipe 死锁
16 | # 限速
17 | # not ready_to_serv host set保存host
18 | # 获得可用源就不再去请求server
19 | # client 线程数限制,find no client slot what response?
20 | # 心跳监测
21 | # 路径处理,目的文件夹不存在
22 | # server到不了 就会hang
23 | # help函数
24 | # SO_RCVBUF
25 | # option pool大小
26 | # quit_job_s 如果host不在的逻辑
27 | # serv pool 满了的心跳检测
28 | # 退出任务广播
29 | # 单文件支持
30 | # join 超时探测
31 | # join 进度传递
32 | # getopt_long()
33 | # 续传
34 | # 在sheldon上 recv 的 MSG_WAITALL 貌似不起作用
35 | # xor_hash过程中 job erase 导致core https://computing.llnl.gov/tutorials/pthreads/man/pthread_setcanceltype.txt
36 | # 迁移到libev?
37 | # 异常文件处理
38 | # job—state
39 | # client日志默认输出至stderr
40 | # client正常退出打印一条日志
41 | # client做种时间可以配置
42 | # 续传模式在目的文件被mv走可能引发的bug
43 | # sig handler
44 | # dead不彻底摘除 增加时延 pthread_cancel 用时◎◎◎
45 |
46 | free all job 函数
47 | 消除满地的exit
48 | 在二期增加--follow-link开关,一期只采用不follow的处理方式
49 | 做种限速
50 |
51 |
52 | 路径通配符
53 | Server单点消除
54 | 源路径是软链接
55 | 流式P2P
56 | job 过期
57 | # xor_hash int 读提速 没有作用
58 | # sep_arg 返回值检查
59 | # JOIN 不存在的目录引发 clnt core
60 |
61 | ###############profile###############
62 | Flat profile:
63 |
64 | Each sample counts as 0.01 seconds.
65 | % cumulative self self total
66 | time seconds seconds calls ms/call ms/call name
67 | 98.27 0.85 0.85 213 3.97 3.97 digest_ok(void*, _s_block*)
68 | 1.16 0.86 0.01 vnode_download(void*)
69 | 0.58 0.86 0.01 175 0.03 0.03 writeblock(_s_job*, unsigned char const*, _s_block*)
70 | 0.00 0.86 0.00 159 0.00 0.00 bw_down_limit(int)
71 | 0.00 0.86 0.00 62 0.00 0.00 ev_fn_write(int, short, void*)
72 | 0.00 0.86 0.00 62 0.00 0.00 gethostname_my(char const*, hostent*, char**, unsigned long)
73 | 0.00 0.86 0.00 62 0.00 0.00 sendall(int, void const*, int, int)
74 | 0.00 0.86 0.00 61 0.00 0.00 connect_host(_s_host*, int, int)
75 | 0.00 0.86 0.00 61 0.00 0.00 sep_arg(char*, char**, int)
76 | 0.00 0.86 0.00 59 0.00 13.12 get_blocks_c(_s_host*, long, long, unsigned char, char*)
77 | 0.00 0.86 0.00 54 0.00 0.00 close_socket(int)
78 | 0.00 0.86 0.00 54 0.00 0.00 cmpByDistance(_s_host const&, _s_host const&)
79 | 0.00 0.86 0.00 45 0.00 0.00 operator==(_s_host const&, _s_host const&)
80 | 0.00 0.86 0.00 36 0.00 0.00 __gnu_cxx::__normal_iterator<_s_host*, std::vector<_s_host, std::allocator<_s_host> > > std::__find<__gnu_cxx::__normal_iterator<_s_host*, std::vector<_s_host, std::allocator<_s_host> > >, _s_host>(__gnu_cxx::__normal_iterator<_s_host*, std::vector<_s_host, std::allocator<_s_host> > >, __gnu_cxx::__normal_iterator<_s_host*, std::vector<_s_host, std::allocator<_s_host> > >, _s_host const&, std::random_access_iterator_tag)
81 | 0.00 0.86 0.00 27 0.00 19.34 decide_src(_s_job*, int, long, std::vector<_s_host, std::allocator<_s_host> >*, _s_host*)
82 | 0.00 0.86 0.00 27 0.00 0.00 get_blk_src(_s_job*, int, long, std::vector<_s_host, std::allocator<_s_host> >*)
83 | 0.00 0.86 0.00 20 0.00 0.00 thread_worker_new(int)
84 | 0.00 0.86 0.00 19 0.00 0.00 gettimestr(char*)
85 | 0.00 0.86 0.00 19 0.00 0.00 gko_log(WARNING, char const*, ...)
86 | 0.00 0.86 0.00 18 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::_M_insert_unique(_s_host const&)
87 | 0.00 0.86 0.00 12 0.00 0.00 conn_client_clear(conn_client*)
88 | 0.00 0.86 0.00 9 0.00 0.00 conn_client_free(conn_client*)
89 | 0.00 0.86 0.00 9 0.00 0.00 conn_tcp_server_on_data(int, short, void*)
90 | 0.00 0.86 0.00 9 0.00 0.00 parse_req(char*)
91 | 0.00 0.86 0.00 9 0.00 0.00 std::vector<_s_host, std::allocator<_s_host> >::_M_insert_aux(__gnu_cxx::__normal_iterator<_s_host*, std::vector<_s_host, std::allocator<_s_host> > >, _s_host const&)
92 | 0.00 0.86 0.00 8 0.00 0.00 conn_send_data(int, void*, unsigned int)
93 | 0.00 0.86 0.00 8 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, _s_host const&)
94 | 0.00 0.86 0.00 7 0.00 0.00 conn_setnonblock(int)
95 | 0.00 0.86 0.00 6 0.00 0.00 sendblocks(int, _s_job*, long, long)
96 | 0.00 0.86 0.00 6 0.00 0.00 get_blocks_s(void*, int)
97 | 0.00 0.86 0.00 6 0.00 0.00 add_new_conn_client(int)
98 | 0.00 0.86 0.00 6 0.00 0.00 conn_client_list_get(int)
99 | 0.00 0.86 0.00 6 0.00 0.00 thread_list_find_next()
100 | 0.00 0.86 0.00 6 0.00 0.00 thread_worker_process(int, short, void*)
101 | 0.00 0.86 0.00 6 0.00 0.00 conn_tcp_server_accept(int, short, void*)
102 | 0.00 0.86 0.00 6 0.00 0.00 thread_worker_dispatch(int)
103 | 0.00 0.86 0.00 6 0.00 0.00 host_hash(_s_job*, _s_host const*, _s_host_hash_result*, char)
104 | 0.00 0.86 0.00 5 0.00 0.00 inplace_strip_tailing_slash(char*)
105 | 0.00 0.86 0.00 4 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::erase(_s_host const&)
106 | 0.00 0.86 0.00 3 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::_M_erase(std::_Rb_tree_node<_s_host>*)
107 | 0.00 0.86 0.00 2 0.00 0.00 merge_path(char*, char const*, char const*)
108 | 0.00 0.86 0.00 2 0.00 0.00 new_host_s(void*, int)
109 | 0.00 0.86 0.00 2 0.00 0.00 inplace_change_path(char*, char const*, char const*)
110 | 0.00 0.86 0.00 2 0.00 0.00 base_name(char*, char const*)
111 |
112 | Flat profile:
113 | Each sample counts as 0.01 seconds.
114 | % cumulative self self total
115 | time seconds seconds calls ms/call ms/call name
116 | 100.01 2.05 2.05 596 3.44 3.44 xor_hash_file(unsigned int, _IO_FILE*, long*, unsigned long*, unsigned char*)
117 | 0.00 2.05 0.00 3054 0.00 0.00 conn_client_free(conn_client*)
118 | 0.00 2.05 0.00 1474 0.00 0.00 ev_fn_gsendfile(int, short, void*)
119 | 0.00 2.05 0.00 248 0.00 0.00 sendfileall(int, int, long*, unsigned long*)
120 | 0.00 2.05 0.00 107 0.00 0.00 conn_client_clear(conn_client*)
121 | 0.00 2.05 0.00 62 0.00 0.00 sendall(int, void const*, int, int)
122 | 0.00 2.05 0.00 61 0.00 0.00 ev_fn_write(int, short, void*)
123 | 0.00 2.05 0.00 55 0.00 0.00 conn_setnonblock(int)
124 | 0.00 2.05 0.00 54 0.00 0.00 conn_send_data(int, void*, unsigned int)
125 | 0.00 2.05 0.00 54 0.00 0.00 add_new_conn_client(int)
126 | 0.00 2.05 0.00 54 0.00 0.00 conn_client_list_get(int)
127 | 0.00 2.05 0.00 54 0.00 0.00 thread_list_find_next()
128 | 0.00 2.05 0.00 54 0.00 0.00 thread_worker_process(int, short, void*)
129 | 0.00 2.05 0.00 54 0.00 0.00 thread_worker_dispatch(int)
130 | 0.00 2.05 0.00 54 0.00 0.00 conn_tcp_server_on_data(int, short, void*)
131 | 0.00 2.05 0.00 53 0.00 0.00 conn_tcp_server_accept(int, short, void*)
132 | 0.00 2.05 0.00 53 0.00 0.00 parse_req(char*)
133 | 0.00 2.05 0.00 52 0.00 0.00 sep_arg(char*, char**, int)
134 | 0.00 2.05 0.00 48 0.00 0.00 sendblocks(int, _s_job*, long, long)
135 | 0.00 2.05 0.00 48 0.00 0.00 get_blocks_s(void*, int)
136 | 0.00 2.05 0.00 20 0.00 0.00 thread_worker_new(int)
137 | 0.00 2.05 0.00 5 0.00 0.00 connect_host(_s_host*, int, int)
138 | 0.00 2.05 0.00 5 0.00 0.00 gethostname_my(char const*, hostent*, char**, unsigned long)
139 | 0.00 2.05 0.00 5 0.00 0.00 sendcmd(_s_host*, char const*, int, int)
140 | 0.00 2.05 0.00 4 0.00 0.00 close_socket(int)
141 | 0.00 2.05 0.00 2 0.00 0.00 join_job_s(void*, int)
142 | 0.00 2.05 0.00 2 0.00 0.00 quit_job_s(void*, int)
143 | 0.00 2.05 0.00 2 0.00 0.00 helo_serv_s(void*, int)
144 | 0.00 2.05 0.00 2 0.00 0.00 broadcast_join(_s_host*, _s_host*)
145 | 0.00 2.05 0.00 2 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, _s_host const&)
146 | 0.00 2.05 0.00 2 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::erase(_s_host const&)
147 | 0.00 2.05 0.00 2 0.00 0.00 std::_Rb_tree<_s_host, _s_host, std::_Identity<_s_host>, std::less<_s_host>, std::allocator<_s_host> >::_M_erase(std::_Rb_tree_node<_s_host>*)
148 | 0.00 2.05 0.00 2 0.00 0.00 std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_M_erase(std::_Rb_tree_node >*)
149 | 0.00 2.05 0.00 1 0.00 0.00 global constructors keyed to grand_lock
150 | 0.00 2.05 0.00 1 0.00 0.00 conn_close()
151 | 0.00 2.05 0.00 1 0.00 0.00 recurse_dir(_s_job*)
152 | 0.00 2.05 0.00 1 0.00 0.00 thread_init()
153 | 0.00 2.05 0.00 1 0.00 0.00 xor_hash_all(_s_job*, long)
154 | 0.00 2.05 0.00 1 0.00 0.00 get_file_count(char const*)
155 | 0.00 2.05 0.00 1 0.00 0.00 conn_tcp_server(conn_server*)
156 | 0.00 2.05 0.00 1 0.00 0.00 conn_client_list_init()
157 | 0.00 2.05 0.00 1 0.00 0.00 set_sig()
158 | 0.00 2.05 0.00 1 0.00 0.00 base_init()
159 | 0.00 2.05 0.00 1 0.00 0.00 erase_job(std::string&)
160 | 0.00 2.05 0.00 1 0.00 0.00 std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair const&)
161 | 0.00 2.05 0.00 1 0.00 0.00 std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::_M_insert_unique(std::pair const&)
162 | 0.00 2.05 0.00 1 0.00 0.00 std::_Rb_tree, std::_Select1st >, std::less, std::allocator
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #include "event.h"
29 |
30 | /// Thread worker
31 | struct thread_worker
32 | {
33 | int id;
34 | pthread_t tid;
35 | struct event_base *ev_base;
36 | struct event ev_notify;
37 | int notify_recv_fd;
38 | int notify_send_fd;
39 | };
40 |
41 | /// Connection client
42 | struct conn_client
43 | {
44 | int id;
45 | int client_fd;
46 | unsigned long client_addr;
47 | int client_port;
48 | unsigned int conn_time;
49 | func_t handle_client;
50 | struct event ev_read;
51 | char *read_buffer;
52 | unsigned int buffer_size;
53 | };
54 |
55 | /// Connection server struct
56 | struct conn_server
57 | {
58 | char is_server;
59 | int listen_fd;
60 | struct sockaddr_in listen_addr;
61 | in_addr_t srv_addr;
62 | int srv_port;
63 | unsigned int start_time;
64 | int nonblock;
65 | int listen_queue_length;
66 | int tcp_send_buffer_size;
67 | int tcp_recv_buffer_size;
68 | int send_timeout;
69 | int tcp_reuse;
70 | int tcp_nodelay;
71 | struct event ev_accept;
72 | void (* on_data_callback)(int, void *, unsigned int);
73 | };
74 |
75 | class gko_pool
76 | {
77 | public:
78 | static s_host_t gko_serv;
79 |
80 | static gko_pool *getInstance();
81 | static void setFuncTable(char(*cmd_list)[CMD_LEN], func_t * func_list,
82 | int cmdcount);
83 |
84 | int getPort() const;
85 | void setPort(int port);
86 | s_option_t *getOption() const;
87 | void setOption(s_option_t *option);
88 |
89 | /// close conn, shutdown && close
90 | int conn_close();
91 | /// global run func
92 | int gko_run();
93 | int gko_loopexit(int timeout);
94 |
95 | private:
96 | static gko_pool * _instance;
97 | /// FUNC DICT
98 | static char (* cmd_list_p)[CMD_LEN];
99 | ///server func list
100 | static func_t * func_list_p;
101 | /// cmd type conut
102 | static int cmd_count;
103 | /// global lock
104 | static pthread_mutex_t instance_lock;
105 |
106 | int g_curr_thread;
107 | struct thread_worker ** g_worker_list;
108 | struct event_base *g_ev_base;
109 | int g_total_clients;
110 | struct conn_client **g_client_list;
111 | struct conn_server *g_server;
112 | int port;
113 | s_option_t * option;
114 |
115 | static void conn_send_data(int fd, void *str, unsigned int len);
116 | /// Accept new connection
117 | static void conn_tcp_server_accept(int fd, short ev, void *arg);
118 | /// close conn, shutdown && close
119 | static void * thread_worker_init(void *arg);
120 | /// close conn, shutdown && close
121 | static void thread_worker_process(int fd, short ev, void *arg);
122 | /// Event on data from client
123 | static void conn_tcp_server_on_data(int fd, short ev, void *arg);
124 | /// parse the request return the proper func handle num
125 | static int parse_req(char *req);
126 |
127 | int thread_worker_new(int id);
128 | int thread_list_find_next(void);
129 | int conn_client_list_init(void);
130 | int gingko_serv_async_server_base_init(void);
131 | int gingko_clnt_async_server_base_init(s_host_t * the_host);
132 | int gko_async_server_base_init(void);
133 | /// Accept new connection, start listen etc.
134 | int conn_tcp_server(struct conn_server *c);
135 | /// Accept new connection
136 | struct conn_client * add_new_conn_client(int client_fd);
137 | /// Event on data from client
138 | int conn_client_list_find_free();
139 | /// clear client struct
140 | int conn_client_clear(struct conn_client *client);
141 | /// clear the "session"
142 | int conn_client_free(struct conn_client *client);
143 | /// Get client object from pool by given client_id
144 | struct conn_client * conn_client_list_get(int id);
145 | /// Dispatch to worker
146 | void thread_worker_dispatch(int sig_id);
147 | /// init the whole thread pool
148 | int thread_init();
149 | /// construct func
150 | gko_pool(const int pt);
151 | /// another construct func
152 | gko_pool();
153 | };
154 |
155 | #endif /** ASYNC_POOL_H_ **/
156 |
--------------------------------------------------------------------------------
/src/async_threads.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * async_threads.cpp
3 | * gingko
4 | *
5 | * Created by Auxten on 11-4-16.
6 | * Copyright 2011 Baidu. All rights reserved.
7 | *
8 | **/
9 |
10 | #include "gingko.h"
11 | #include "async_pool.h"
12 | #include "log.h"
13 |
14 | /**
15 | * @brief create new thread worker
16 | *
17 | * @see
18 | * @note
19 | * @author auxten
20 | * @date 2011-8-1
21 | **/
22 | int gko_pool::thread_worker_new(int id)
23 | {
24 | int ret;
25 |
26 | struct thread_worker *worker = new struct thread_worker;
27 | if(! worker)
28 | {
29 | gko_log(FATAL, "new thread_worker failed");
30 | return -1;
31 | }
32 |
33 | int fds[2];
34 | if (pipe(fds) != 0)
35 | {
36 | gko_log(FATAL, "pipe error");
37 | return -1;
38 | }
39 | worker->notify_recv_fd = fds[0];
40 | worker->notify_send_fd = fds[1];
41 |
42 | worker->ev_base = (struct event_base*)event_init();
43 | if (!worker->ev_base)
44 | {
45 | gko_log(FATAL, "Worker event base initialize error");
46 | return -1;
47 | }
48 |
49 | pthread_attr_t thread_attr;
50 | pthread_attr_init(&thread_attr);
51 | pthread_attr_setstacksize(&thread_attr, MYSTACKSIZE);
52 | ///pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
53 | ret = pthread_create(&worker->tid, &thread_attr, thread_worker_init,
54 | (void *) worker);
55 | if (ret)
56 | {
57 | gko_log(FATAL, "Thread create error");
58 | return -1;
59 | }
60 | worker->id = id;
61 | *(g_worker_list + id) = worker;
62 | ///gko_log(NOTICE, "thread_worker_new :%d",(*(g_worker_list+id))->notify_send_fd );
63 | return 0;
64 | }
65 |
66 | /**
67 | * @brief Worker initialize
68 | *
69 | * @see
70 | * @note
71 | * @author auxten
72 | * @date 2011-8-1
73 | **/
74 | void * gko_pool::thread_worker_init(void *arg)
75 | {
76 | struct thread_worker *worker = (struct thread_worker *) arg;
77 | event_set(&worker->ev_notify, worker->notify_recv_fd, EV_READ | EV_PERSIST,
78 | thread_worker_process, worker);
79 | event_base_set(worker->ev_base, &worker->ev_notify);
80 | event_add(&worker->ev_notify, 0);
81 | event_base_loop(worker->ev_base, 0);
82 |
83 | return NULL;
84 | }
85 |
86 | /**
87 | * @brief Transfer a new event to worker
88 | *
89 | * @see
90 | * @note
91 | * @author auxten
92 | * @date 2011-8-1
93 | **/
94 | void gko_pool::thread_worker_process(int fd, short ev, void *arg)
95 | {
96 | struct thread_worker *worker = (struct thread_worker *) arg;
97 | int c_id;
98 | read(fd, &c_id, sizeof(int));
99 | struct conn_client *client = gko_pool::getInstance()->conn_client_list_get(c_id);
100 |
101 | if (client->client_fd)
102 | {
103 | event_set(&client->ev_read, client->client_fd, EV_READ | EV_PERSIST,
104 | conn_tcp_server_on_data, (void *) client);
105 | event_base_set(worker->ev_base, &client->ev_read);
106 | if (-1 == event_add(&client->ev_read, 0))
107 | {
108 | gko_log(WARNING, "Cannot handle client's data event");
109 | }
110 | }
111 | else
112 | {
113 | gko_log(WARNING, "conn_client_list_get error");
114 | }
115 | return;
116 | }
117 |
118 | /**
119 | * @brief find an availiable thread, return thread index; on error
120 | * return -1
121 | *
122 | * @see
123 | * @note
124 | * @author auxten
125 | * @date 2011-8-1
126 | **/
127 | int gko_pool::thread_list_find_next()
128 | {
129 | int i;
130 | int tmp;
131 |
132 | for (i = 0; i < option->worker_thread; i++)
133 | {
134 | tmp = (i + g_curr_thread + 1) % option->worker_thread;
135 | if (*(g_worker_list + tmp) && (*(g_worker_list + tmp))->tid)
136 | {
137 | g_curr_thread = tmp;
138 | return tmp;
139 | }
140 | }
141 | gko_log(WARNING, "thread pool full");
142 | return -1;
143 | }
144 |
145 | /**
146 | * @brief init the whole thread pool
147 | *
148 | * @see
149 | * @note
150 | * @author auxten
151 | * @date 2011-8-1
152 | **/
153 | int gko_pool::thread_init()
154 | {
155 | int i;
156 | g_worker_list = new struct thread_worker *[option->worker_thread];
157 | if (! g_worker_list)
158 | {
159 | gko_log(FATAL, "new new struct thread_worker *[option->worker_thread] failed");
160 | return -1;
161 | }
162 | memset(g_worker_list, 0, sizeof(struct thread_worker *) * option->worker_thread);
163 | for (i = 0; i < option->worker_thread; i++)
164 | {
165 | if(thread_worker_new(i) != 0)
166 | {
167 | gko_log(FATAL, FLF("thread_worker_new error"));
168 | return -1;
169 | }
170 | }
171 |
172 | return 0;
173 | }
174 |
175 | /**
176 | * @brief parse the request return the proper func handle num
177 | *
178 | * @see
179 | * @note
180 | * @author auxten
181 | * @date 2011-8-1
182 | **/
183 | int gko_pool::parse_req(char *req)
184 | {
185 | int i;
186 | if (UNLIKELY(!req))
187 | {
188 | return cmd_count - 1;
189 | }
190 | for (i = 0; i < cmd_count - 1; i++)
191 | {
192 | if (cmd_list_p[i][0] == req[0] && //todo use int
193 | cmd_list_p[i][1] == req[1] &&
194 | cmd_list_p[i][2] == req[2] &&
195 | cmd_list_p[i][3] == req[3])
196 | {
197 | break;
198 | }
199 | }
200 | return i;
201 | }
202 |
203 |
204 | /**
205 | * @brief Dispatch to worker
206 | *
207 | * @see
208 | * @note
209 | * @author auxten
210 | * @date 2011-8-1
211 | **/
212 | void gko_pool::thread_worker_dispatch(int c_id)
213 | {
214 | int worker_id;
215 | int res;
216 | worker_id = thread_list_find_next();
217 | if (worker_id < 0)
218 | {
219 | gko_log(WARNING, "can't find available thread");
220 | return;
221 | }
222 | res = write((*(g_worker_list + worker_id))->notify_send_fd, &c_id,
223 | sizeof(int));
224 | if (res == -1)
225 | {
226 | gko_log(WARNING, "Pipe write error");
227 | }
228 | }
229 |
230 | int gko_pool::gko_loopexit(int timeout)
231 | {
232 | struct timeval timev;
233 |
234 | timev.tv_sec = timeout;
235 | timev.tv_usec = 0;
236 | event_base_loopexit(g_ev_base, (timeout ? &timev : NULL));
237 | return 0;
238 | }
239 |
240 |
241 |
--------------------------------------------------------------------------------
/src/autogen.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then
3 | exec autoreconf --verbose --force -i
4 | fi
5 |
6 | LIBTOOLIZE=libtoolize
7 | SYSNAME=`uname`
8 | if [ "x$SYSNAME" = "xDarwin" ] ; then
9 | LIBTOOLIZE=glibtoolize
10 | fi
11 | aclocal && \
12 | autoheader && \
13 | autoconf && \
14 | automake --add-missing --force-missing --copy
15 |
--------------------------------------------------------------------------------
/src/clnt_unittest.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * clnt_unittest.cpp
3 | *
4 | * Created on: 2011-8-15
5 | * Author: auxten
6 | */
7 |
8 | #define UNITTEST
9 | #ifndef GINGKO_CLNT
10 | #define GINGKO_CLNT
11 | #endif /** GINGKO_CLNT **/
12 |
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #ifdef __APPLE__
37 | #include
38 | #else
39 | #include
40 | #endif /** __APPLE__ **/
41 |
42 | #include "gingko.h"
43 | #include "async_pool.h"
44 | #include "hash/xor_hash.h"
45 | #include "path.h"
46 | #include "route.h"
47 | #include "log.h"
48 | #include "snap.h"
49 | #include "option.h"
50 | #include "socket.h"
51 | #include "limit.h"
52 | #include "job_state.h"
53 | #include "gingko_clnt.h"
54 |
55 |
56 | /************** PTHREAD STUFF **************/
57 | ///default pthread_attr_t
58 | pthread_attr_t g_attr;
59 | ///client wide lock
60 | pthread_mutex_t g_clnt_lock;
61 | ///block host set lock
62 | pthread_mutex_t g_blk_hostset_lock;
63 | ///mutex for gko.hosts_new_noready
64 | pthread_mutex_t g_hosts_new_noready_mutex;
65 | ///mutex for gko.hosts_del_noready
66 | pthread_mutex_t g_hosts_del_noready_mutex;
67 | /************** PTHREAD STUFF **************/
68 |
69 | /// the g_job assoiate with the client
70 | s_job_t g_job;
71 |
72 | /// gingko global stuff
73 | s_gingko_global_t gko;
74 |
75 | #ifdef UNITTEST
76 |
77 | #include "gtest/gtest.h"
78 | #include "unittest.h"
79 |
80 | /************** FUNC DICT **************/
81 | #include "gingko_common.h"
82 | /************** FUNC DICT **************/
83 |
84 | GINGKO_OVERLOAD_S_HOST_LT
85 |
86 |
87 | int clnt_unittest_init()
88 | {
89 | memset(&g_job, 0, sizeof(g_job));
90 | memset(&gko, 0, sizeof(gko));
91 | memset(&gko.the_serv, 0, sizeof(gko.the_serv));
92 |
93 | gko.opt.limit_up_rate = CLNT_LIMIT_UP_RATE;
94 | gko.opt.limit_down_rate = CLNT_LIMIT_DOWN_RATE;
95 | gko.opt.worker_thread = CLNT_ASYNC_THREAD_NUM;
96 | gko.opt.connlimit = CLNT_POOL_SIZE;
97 | gko.opt.bind_ip = htons(INADDR_ANY);
98 | gko.the_serv.port = SERV_PORT;
99 | gko.ready_to_serv = 0;
100 | gko.snap_fd = -2;
101 | strncpy(gko.opt.logpath, CLIENT_LOG, sizeof(gko.opt.logpath));
102 |
103 | umask(0);
104 |
105 | return 0;
106 | }
107 |
108 |
109 | /// path.cpp
110 | /**
111 | * @brief ../path//// TO ../path
112 | * @brief ../path/ TO ../path
113 | * @brief ../path TO ../path
114 | *
115 | * @see
116 | * @note
117 | * @author auxten
118 | * @date 2011-8-1
119 | **/
120 | TEST(inplace_strip_tailing_slash, with1slash)
121 | {
122 | char test_path1[MAX_PATH_LEN];
123 | strncpy(test_path1, "aaa/", MAX_PATH_LEN);
124 | char * test_rslt = "aaa";
125 | inplace_strip_tailing_slash(test_path1);
126 | EXPECT_STREQ(test_rslt, test_path1);
127 | }
128 |
129 | TEST(inplace_strip_tailing_slash, withmoreslash)
130 | {
131 | char test_path1[MAX_PATH_LEN];
132 | strncpy(test_path1, "aaa////", MAX_PATH_LEN);
133 | char * test_rslt = "aaa";
134 | inplace_strip_tailing_slash(test_path1);
135 | EXPECT_STREQ(test_rslt, test_path1);
136 | }
137 |
138 | TEST(inplace_strip_tailing_slash, withnoslash)
139 | {
140 | char test_path1[MAX_PATH_LEN];
141 | strncpy(test_path1, "aaa", MAX_PATH_LEN);
142 | char * test_rslt = "aaa";
143 | inplace_strip_tailing_slash(test_path1);
144 | EXPECT_STREQ(test_rslt, test_path1);
145 | }
146 |
147 | /**
148 | * @brief ../path/// TO ../path/
149 | * @brief ../path/ TO ../path/
150 | * @brief ../path TO ../path/
151 | *
152 | * @see
153 | * @note
154 | * @author auxten
155 | * @date 2011-8-1
156 | **/
157 | TEST(inplace_add_tailing_slash, with1slash)
158 | {
159 | char test_path1[MAX_PATH_LEN];
160 | strncpy(test_path1, "aaa/", MAX_PATH_LEN);
161 | char * test_rslt = "aaa/";
162 | inplace_add_tailing_slash(test_path1);
163 | EXPECT_STREQ(test_rslt, test_path1);
164 | }
165 |
166 | TEST(inplace_add_tailing_slash, withmoreslash)
167 | {
168 | char test_path1[MAX_PATH_LEN];
169 | strncpy(test_path1, "aaa////", MAX_PATH_LEN);
170 | char * test_rslt = "aaa/";
171 | inplace_add_tailing_slash(test_path1);
172 | EXPECT_STREQ(test_rslt, test_path1);
173 | }
174 |
175 | TEST(inplace_add_tailing_slash, withnoslash)
176 | {
177 | char test_path1[MAX_PATH_LEN];
178 | strncpy(test_path1, "aaa", MAX_PATH_LEN);
179 | char * test_rslt = "aaa/";
180 | inplace_add_tailing_slash(test_path1);
181 | EXPECT_STREQ(test_rslt, test_path1);
182 | }
183 |
184 | /**
185 | * @brief get the base name of a string,
186 | * @brief if out not NULL, cp the base path to out
187 | * @brief return the base path len
188 | *
189 | * @see
190 | * @note
191 | * for example:
192 | * /home/work/opdir -> 11
193 | * ^
194 | * ./dir -> 2
195 | * ^
196 | * dir -> 0
197 | * ^
198 | * ../file -> 3
199 | * ^
200 | * @author auxten
201 | * @date 2011-8-1
202 | **/
203 | TEST(get_base_name_index, 1)
204 | {
205 | char test_path1[MAX_PATH_LEN];
206 |
207 | EXPECT_EQ(get_base_name_index(test_path1, "/home/work/opdir"), 11);
208 | EXPECT_STREQ("opdir", test_path1);
209 | }
210 |
211 | TEST(get_base_name_index, 2)
212 | {
213 | char test_path1[MAX_PATH_LEN];
214 |
215 | EXPECT_EQ(get_base_name_index(test_path1, "./dir"), 2);
216 | EXPECT_STREQ("dir", test_path1);
217 | }
218 |
219 | TEST(get_base_name_index, 3)
220 | {
221 | char test_path1[MAX_PATH_LEN];
222 |
223 | EXPECT_EQ(get_base_name_index(test_path1, "dir"), 0);
224 | EXPECT_STREQ("dir", test_path1);
225 | }
226 |
227 | TEST(get_base_name_index, 4)
228 | {
229 | char test_path1[MAX_PATH_LEN];
230 |
231 | EXPECT_EQ(get_base_name_index(test_path1, "../file"), 3);
232 | EXPECT_STREQ("file", test_path1);
233 | }
234 |
235 | TEST(get_base_name_index, 5)
236 | {
237 | char test_path1[MAX_PATH_LEN];
238 |
239 | EXPECT_EQ(get_base_name_index(test_path1, "../file/"), 8);
240 | EXPECT_STREQ("", test_path1);
241 | }
242 |
243 | /**
244 | * @brief in : const char * dir_name, const char * base_name
245 | * @brief out : dir_name/base_name
246 | *
247 | * @see
248 | * @note
249 | * @author auxten
250 | * @date 2011-8-1
251 | **/
252 | TEST(merge_path, normal)
253 | {
254 | char result[MAX_PATH_LEN];
255 | EXPECT_EQ(0, merge_path(result, "dirname", "basename"));
256 | EXPECT_STREQ("dirname/basename", result);
257 | }
258 |
259 | TEST(merge_path, dirwithslash)
260 | {
261 | char result[MAX_PATH_LEN];
262 | EXPECT_EQ(0, merge_path(result, "dirname/", "basename"));
263 | EXPECT_STREQ("dirname/basename", result);
264 | }
265 |
266 | TEST(merge_path, dirwith2slash)
267 | {
268 | char result[MAX_PATH_LEN];
269 | EXPECT_EQ(0, merge_path(result, "dirname//", "basename"));
270 | EXPECT_STREQ("dirname/basename", result);
271 | }
272 |
273 | /**
274 | * @brief change remote path to local path, store it in path
275 | *
276 | * @see
277 | * @note
278 | * path: ../test/.DS_Store
279 | * req_path: ../test
280 | * local_path: ../output2/
281 | * if (dst_path_exist)
282 | * path output: ../output2/test/.DS_Store
283 | * else
284 | * path output: ../output2/.DS_Store
285 | * @author auxten
286 | * @date 2011-8-1
287 | **/
288 | TEST(change_to_local_path, dst_path_exist)
289 | {
290 | char path[MAX_PATH_LEN];
291 | strncpy(path, "../test/.DS_Store", MAX_PATH_LEN);
292 | EXPECT_EQ(0, change_to_local_path(path, "../test", "../output2/", 1));
293 | EXPECT_STREQ("../output2/test/.DS_Store", path);
294 | }
295 |
296 | TEST(change_to_local_path, dst_path_nonexist)
297 | {
298 | char path[MAX_PATH_LEN];
299 | strncpy(path, "../test/.DS_Store", MAX_PATH_LEN);
300 | EXPECT_EQ(0, change_to_local_path(path, "../test", "../output2/", 0));
301 | EXPECT_STREQ("../output2/.DS_Store", path);
302 | }
303 |
304 | /**
305 | * @brief change current working dir path to absolute path
306 | *
307 | * @see
308 | * @note
309 | * result is stored in abs_path
310 | * return abs_path on succeed else NULL
311 | * @author auxten
312 | * @date 2011-8-1
313 | **/
314 | TEST(cwd_path_to_abs_path, relative_path)
315 | {
316 | char path[MAX_PATH_LEN];
317 | char orig_path[MAX_PATH_LEN];
318 | EXPECT_NE((char *)NULL, getcwd(orig_path, MAX_PATH_LEN));
319 | EXPECT_EQ(0, chdir("/home"));
320 | EXPECT_NE((char *)NULL, cwd_path_to_abs_path(path, "work"));
321 | EXPECT_STREQ("/home/work", path);
322 | EXPECT_EQ(0, chdir(orig_path));
323 | }
324 |
325 | TEST(cwd_path_to_abs_path, abs_path)
326 | {
327 | char path[MAX_PATH_LEN];
328 | EXPECT_NE((char *)NULL, cwd_path_to_abs_path(path, "/work"));
329 | EXPECT_STREQ("/work", path);
330 | }
331 |
332 | /**
333 | * @brief get the symlink dest's absolute path, store it in abs_path
334 | *
335 | * @see
336 | * @note
337 | * @author auxten
338 | * @date 2011-8-1
339 | **/
340 | TEST(symlink_dest_to_abs_path, symlink_to_relative_path)
341 | {
342 | char path[MAX_PATH_LEN];
343 | char path2[MAX_PATH_LEN];
344 | EXPECT_NE((char *)NULL, getcwd(path2, MAX_PATH_LEN));
345 | strncat(path2, "/../testcase/test.sh", MAX_PATH_LEN);
346 | EXPECT_NE((char *)NULL, symlink_dest_to_abs_path(path, "../testcase/test.sh.ln"));
347 | EXPECT_STREQ(path2, path);
348 | }
349 |
350 | TEST(symlink_dest_to_abs_path, symlink_to_abs_path)
351 | {
352 | char path[MAX_PATH_LEN];
353 | EXPECT_NE((char *)NULL, symlink_dest_to_abs_path(path, "../testcase/test.sh.absln"));
354 | EXPECT_STREQ("/home/auxten", path);
355 | }
356 |
357 | ///socket.cpp
358 | /**
359 | * @brief connect to a host
360 | *
361 | * @see
362 | * @note
363 | * h: pointer to s_host_t
364 | * recv_sec: receive timeout seconds, 0 for never timeout
365 | * return the socket when succ
366 | * return < 0 when error, specially HOST_DOWN_FAIL indicate host dead
367 | * @author auxten
368 | * @date 2011-8-1
369 | **/
370 | TEST(socket, Connect_host_Setnonblock_Setblock_Close_socket)
371 | {
372 | int fd, flags;
373 | s_host_t h = {"localhost", 22};
374 |
375 | ///establish socket
376 | fd = connect_host(&h, 5, 5);
377 | EXPECT_LE(0, fd);
378 |
379 | ///setnonblock
380 | EXPECT_EQ(0, setnonblock(fd));
381 | flags = fcntl(fd, F_GETFL);
382 | EXPECT_LE(0, flags);
383 | EXPECT_NE(0, flags & O_NONBLOCK);
384 |
385 | ///try setnonblock again
386 | EXPECT_EQ(0, setnonblock(fd));
387 | flags = fcntl(fd, F_GETFL);
388 | EXPECT_LE(0, flags);
389 | EXPECT_NE(0, flags & O_NONBLOCK);
390 |
391 | ///setblock
392 | EXPECT_EQ(0, setblock(fd));
393 | flags = fcntl(fd, F_GETFL);
394 | EXPECT_LE(0, flags);
395 | EXPECT_EQ(0, flags & O_NONBLOCK);
396 |
397 | ///try setblock again
398 | EXPECT_EQ(0, setblock(fd));
399 | flags = fcntl(fd, F_GETFL);
400 | EXPECT_LE(0, flags);
401 | EXPECT_EQ(0, flags & O_NONBLOCK);
402 |
403 | ///close socket
404 | EXPECT_EQ(0, close_socket(fd));
405 | }
406 |
407 |
408 | ///options.cpp
409 | /**
410 | * @brief process args for client
411 | *
412 | * @see
413 | * @note
414 | * @author auxten
415 | * @date 2011-8-1
416 | **/
417 | //int clnt_parse_opt(int argc, char *argv[], s_job_t * jo)
418 | TEST(clnt_parse_opt, clnt_parse_opt)
419 | {
420 | const int max_argc = 30;
421 | char argv_test_buf[max_argc][MAX_PATH_LEN] =
422 | {
423 | "gkocp",
424 | "-l",
425 | "./clnt.log",
426 | "127.0.0.1:./src",
427 | "./dest",
428 | "-o", "-c", "-u", "17", "-d", "18", "-r", "19", "-w", "20",
429 | "-t", "21", "-n", "22", "-s", "23", "-b", "127.0.0.1", "-p", "2121", "--debug"
430 | };
431 | char * argv_test[max_argc];
432 | for (int i = 0; i < max_argc; i++)
433 | {
434 | argv_test[i] = (char *)argv_test_buf[i];
435 | }
436 | int argc_test = 26;
437 | EXPECT_EQ(0, clnt_parse_opt(argc_test, argv_test, &g_job));
438 | //EXPECT_EQ(htonl(INADDR_LOOPBACK), gko.opt.bind_ip);
439 | EXPECT_EQ(22, gko.opt.connlimit);
440 | EXPECT_EQ(17*1024*1024, gko.opt.limit_up_rate);
441 | EXPECT_EQ(18*1024*1024, gko.opt.limit_down_rate);
442 | EXPECT_EQ(19*1024*1024, gko.opt.limit_disk_r_rate);
443 | EXPECT_EQ(20*1024*1024, gko.opt.limit_disk_w_rate);
444 | EXPECT_EQ(0, gko.opt.need_help);
445 | EXPECT_EQ(1, gko.opt.need_progress);
446 | EXPECT_EQ(2121, gko.the_serv.port);
447 | EXPECT_EQ(23, gko.opt.seed_time);
448 | EXPECT_EQ(1, gko.opt.to_continue);
449 | EXPECT_EQ(1, gko.opt.to_debug);
450 | EXPECT_EQ(21, gko.opt.worker_thread);
451 | EXPECT_STREQ("./clnt.log", gko.opt.logpath);
452 |
453 | }
454 |
455 | TEST(clnt_show_version, clnt_show_version)
456 | {
457 | EXPECT_NO_FATAL_FAILURE(clnt_show_version());
458 | }
459 |
460 | TEST(clnt_show_help, clnt_show_help)
461 | {
462 | EXPECT_NO_FATAL_FAILURE(clnt_show_help());
463 | }
464 |
465 | int main(int argc, char *argv[])
466 | {
467 | if(clnt_unittest_init() != 0)
468 | {
469 | perror("clnt_unittest_init failed");
470 | exit(1);
471 | }
472 | ::testing::InitGoogleTest(&argc, argv);
473 |
474 | return RUN_ALL_TESTS();
475 | }
476 | #else
477 | int main()
478 | {
479 |
480 | }
481 | #endif /* UNITTEST */
482 |
--------------------------------------------------------------------------------
/src/configure.in:
--------------------------------------------------------------------------------
1 | # -*- Autoconf -*-
2 | # Process this file with autoconf to produce a configure script.
3 |
4 | AC_PREREQ([1.68])
5 | AC_INIT([libxor_hash.a,gingko_serv,gingko_clnt,unittest], [3.14], [blog.optool.net])
6 | AC_CONFIG_SRCDIR([config.h.in])
7 | AM_CONFIG_HEADER([config.h])
8 | #AC_CONFIG_HEADERS([config.h])
9 | AM_INIT_AUTOMAKE([libxor_hash.a,gingko_serv,gingko_clnt,unittest],3.14)
10 |
11 | ##########################################################################
12 | # debug compilation support
13 | ##########################################################################
14 |
15 | AC_MSG_CHECKING([whether to build with debug information])
16 | AC_ARG_ENABLE([debug],
17 | [AS_HELP_STRING([--enable-debug],
18 | [enable debug data generation (def=no)])],
19 | [debugit="$enableval"],
20 | [debugit=no])
21 | AC_MSG_RESULT([$debugit])
22 |
23 | if test x"$debugit" = x"yes"; then
24 | AC_DEFINE([GKO_DEBUG],[],[Debug Mode])
25 | AM_CXXFLAGS="-ggdb -Wall -O0"
26 | else
27 | AC_DEFINE([NGKO_DEBUG],[],[No-debug Mode])
28 | AM_CXXFLAGS="$AM_CXXFLAGS"
29 | fi
30 |
31 | AC_SUBST([AM_CXXFLAGS])
32 | ##########################################################################
33 |
34 | ##########################################################################
35 | # unittest compilation support
36 | ##########################################################################
37 |
38 | AC_MSG_CHECKING([whether to build unittest version])
39 | AC_ARG_ENABLE([unittest],
40 | [AS_HELP_STRING([--enable-unittest],
41 | [enable unittest code generation (def=no)])],
42 | [unittestit="$enableval"],
43 | [unittestit=no])
44 | AC_MSG_RESULT([$unittestit])
45 |
46 | if test x"$unittestit" = x"yes"; then
47 | AC_DEFINE([UNITTEST],[],[Unittest Mode])
48 | AM_CXXFLAGS="-ggdb -Wall"
49 | else
50 | AC_DEFINE([NUNITTEST],[],[No-unittest Mode])
51 | AM_CXXFLAGS="$AM_CXXFLAGS"
52 | fi
53 |
54 | AC_SUBST([AM_CXXFLAGS])
55 | ##########################################################################
56 |
57 | ##########################################################################
58 | # profile compilation support
59 | ##########################################################################
60 |
61 | AC_MSG_CHECKING([whether to build with profile information])
62 | AC_ARG_ENABLE([profile],
63 | [AS_HELP_STRING([--enable-profile],
64 | [enable profile code generation (def=no)])],
65 | [profileit="$enableval"],
66 | [profileit=no])
67 | AC_MSG_RESULT([$profileit])
68 |
69 | if test x"$profileit" = x"yes"; then
70 | AC_DEFINE([PROFILE],[],[Profile Mode])
71 | AM_CXXFLAGS="-ggdb -Wall -lprofiler"
72 | else
73 | AC_DEFINE([NPROFILE],[],[No-profile Mode])
74 | AM_CXXFLAGS="$AM_CXXFLAGS"
75 | fi
76 |
77 | AC_SUBST([AM_CXXFLAGS])
78 | ##########################################################################
79 |
80 | ##########################################################################
81 | # gprofile compilation support
82 | ##########################################################################
83 |
84 | AC_MSG_CHECKING([whether to build with gprofile information])
85 | AC_ARG_ENABLE([gprofile],
86 | [AS_HELP_STRING([--enable-gprofile],
87 | [enable gprofile code generation (def=no)])],
88 | [gprofileit="$enableval"],
89 | [gprofileit=no])
90 | AC_MSG_RESULT([$gprofileit])
91 |
92 | if test x"$gprofileit" = x"yes"; then
93 | AC_DEFINE([GPROFILE],[],[Profile Mode])
94 | AM_CXXFLAGS="-ggdb -Wall -pg"
95 | else
96 | AC_DEFINE([NGPROFILE],[],[No-gprofile Mode])
97 | AM_CXXFLAGS="$AM_CXXFLAGS"
98 | fi
99 |
100 | AC_SUBST([AM_CXXFLAGS])
101 | ##########################################################################
102 |
103 | ##########################################################################
104 | # O3 optimize compilation support
105 | ##########################################################################
106 |
107 | AC_MSG_CHECKING([whether to build with O3 optimization])
108 | AC_ARG_ENABLE([o3],
109 | [AS_HELP_STRING([--enable-o3],
110 | [enable O3 code generation (def=no)])],
111 | [o3it="$enableval"],
112 | [o3it=no])
113 | AC_MSG_RESULT([$o3it])
114 |
115 | if test x"$o3it" = x"yes"; then
116 | AC_DEFINE([O3],[],[O3 Mode])
117 | AM_CXXFLAGS="-Wall -O3 -march=nocona"
118 | else
119 | AC_DEFINE([NO3],[],[No-O3 Mode])
120 | AM_CXXFLAGS="$AM_CXXFLAGS"
121 | fi
122 |
123 | AC_SUBST([AM_CXXFLAGS])
124 | ##########################################################################
125 |
126 | # Checks for programs.
127 | AC_PROG_CXX
128 | AC_PROG_CC
129 | AC_PROG_MAKE_SET
130 |
131 | # Checks for libraries.
132 | AC_SEARCH_LIBS([pthread_rwlock_init], [pthread])
133 | AC_SEARCH_LIBS([clock_gettime], [rt])
134 | AC_PROG_RANLIB
135 |
136 | # Checks for header files.
137 | AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
138 |
139 | # Checks for typedefs, structures, and compiler characteristics.
140 | AC_TYPE_MODE_T
141 | AC_TYPE_SIZE_T
142 |
143 | # Checks for library functions.
144 | AC_FUNC_FORK
145 | AC_CHECK_FUNCS([gethostbyname memset select socket strerror gettimeofday inet_ntoa poll])
146 |
147 | AC_CONFIG_SUBDIRS([hash])
148 | AC_CONFIG_FILES([Makefile hash/Makefile])
149 | AC_OUTPUT
150 |
--------------------------------------------------------------------------------
/src/erase_job.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import telnetlib
3 | import sys
4 |
5 | tn = telnetlib.Telnet('localhost', 2120)
6 | tn.write('ERSE\t%s'% sys.argv[1])
7 | print tn.read_all()
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/gingko_clnt.h:
--------------------------------------------------------------------------------
1 | /*
2 | * gingko_clnt.h
3 | *
4 | * Created on: 2011-8-15
5 | * Author: auxten
6 | */
7 |
8 | #ifndef GINGKO_CLNT_H_
9 | #define GINGKO_CLNT_H_
10 |
11 | /// CORE algrithm: hash the host to the data ring
12 | s_host_hash_result_t * host_hash(s_job_t * jo, const s_host_t * new_host,
13 | s_host_hash_result_t * result, const u_char usage);
14 |
15 | /// sent GET handler
16 | GKO_INT64 get_blocks_c(s_job_t * jo, s_host_t * dhost, GKO_INT64 num,
17 | GKO_INT64 count,
18 | u_char flag, char * buf);
19 |
20 | /// send HELO handler
21 | int helo_serv_c(void * arg, int fd, s_host_t * server);
22 |
23 | /// send JOIN handler
24 | void * join_job_c(void * arg, int fd);
25 |
26 | /// send QUIT handler
27 | int quit_job_c(const s_host_t * quit_host, const s_host_t * server, const char * uri);
28 |
29 | #endif /* GINGKO_CLNT_H_ */
30 |
--------------------------------------------------------------------------------
/src/gingko_serv.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * gingko_serv.cpp
3 | * gingko
4 | *
5 | * Created by Auxten on 11-4-9.
6 | * Copyright 2011 Baidu. All rights reserved.
7 | *
8 | **/
9 |
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #ifdef __APPLE__
33 | #include
34 | #elif defined (__FreeBSD__)
35 | #include
36 | #include
37 | #include
38 | #else
39 | #include
40 | #endif /** __APPLE__ **/
41 |
42 | #include