iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame^] | 1 | open Thrift |
| 2 | module S = TServer |
| 3 | |
| 4 | class t pf st itf otf ipf opf = |
| 5 | object |
| 6 | inherit S.t pf st itf otf ipf opf |
| 7 | method serve = |
| 8 | try |
| 9 | st#listen; |
| 10 | let c = st#accept in |
| 11 | let proc = pf#getProcessor c in |
| 12 | let itrans = itf#getTransport c in |
| 13 | let otrans = try |
| 14 | otf#getTransport c |
| 15 | with e -> itrans#close; raise e |
| 16 | in |
| 17 | let inp = ipf#getProtocol itrans in |
| 18 | let op = opf#getProtocol otrans in |
| 19 | try |
| 20 | while (proc#process inp op) do () done; |
| 21 | itrans#close; otrans#close |
| 22 | with e -> itrans#close; otrans#close; raise e |
| 23 | with _ -> () |
| 24 | end |