xref: /trafficserver/iocore/dns/test_P_DNS.cc (revision affba2de)
1 /** @file
2 
3   A brief file description
4 
5   @section license License
6 
7   Licensed to the Apache Software Foundation (ASF) under one
8   or more contributor license agreements.  See the NOTICE file
9   distributed with this work for additional information
10   regarding copyright ownership.  The ASF licenses this file
11   to you under the Apache License, Version 2.0 (the
12   "License"); you may not use this file except in compliance
13   with the License.  You may obtain a copy of the License at
14 
15       http://www.apache.org/licenses/LICENSE-2.0
16 
17   Unless required by applicable law or agreed to in writing, software
18   distributed under the License is distributed on an "AS IS" BASIS,
19   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20   See the License for the specific language governing permissions and
21   limitations under the License.
22  */
23 
24 #include "P_DNS.h"
25 
26 Diags *diags;
27 struct NetTesterSM : public Continuation {
28   VIO *read_vio;
29   IOBufferReader *reader;
30   NetVConnection *vc;
31   MIOBuffer *buf;
32 
NetTesterSMNetTesterSM33   NetTesterSM(ProxyMutex *_mutex, NetVConnection *_vc) : Continuation(_mutex)
34   {
35     MUTEX_TRY_LOCK(lock, mutex, _vc->thread);
36     ink_release_assert(lock);
37     vc = _vc;
38     SET_HANDLER(&NetTesterSM::handle_read);
39     buf      = new_MIOBuffer(8);
40     reader   = buf->alloc_reader();
41     read_vio = vc->do_io_read(this, INT64_MAX, buf);
42   }
43 
44   int
handle_readNetTesterSM45   handle_read(int event, void *data)
46   {
47     int r;
48     char *str = nullptr;
49     switch (event) {
50     case VC_EVENT_READ_READY:
51       r   = reader->read_avail();
52       str = new char[r + 10];
53       reader->read(str, r);
54       printf("%s", str);
55       fflush(stdout);
56       break;
57     case VC_EVENT_READ_COMPLETE:
58     /* FALLTHROUGH */
59     case VC_EVENT_EOS:
60       r   = reader->read_avail();
61       str = new char[r + 10];
62       reader->read(str, r);
63       printf("%s", str);
64       fflush(stdout);
65     case VC_EVENT_ERROR:
66       vc->do_io_close();
67       // fixme
68       // handle timeout events
69       break;
70     default:
71       ink_release_assert(!"unknown event");
72     }
73     delete[] str;
74     return EVENT_CONT;
75   }
76 };
77 
78 int
main()79 main()
80 {
81 }
82