| 72 | } |
| 73 | |
| 74 | int |
| 75 | CacheTestSM::event_handler(int event, void *data) |
| 76 | { |
| 77 | switch (event) { |
| 78 | case EVENT_INTERVAL: |
| 79 | case EVENT_IMMEDIATE: |
| 80 | cancel_timeout(); |
| 81 | if (cache_action) { |
| 82 | cache_action->cancel(); |
| 83 | cache_action = nullptr; |
| 84 | } |
| 85 | if (cache_vc) { |
| 86 | cache_vc->do_io_close(); |
| 87 | cache_vc = nullptr; |
| 88 | } |
| 89 | cvio = nullptr; |
| 90 | make_request(); |
| 91 | return EVENT_DONE; |
| 92 | |
| 93 | case CACHE_EVENT_LOOKUP_FAILED: |
| 94 | case CACHE_EVENT_LOOKUP: |
| 95 | goto Lcancel_next; |
| 96 | |
| 97 | case CACHE_EVENT_OPEN_READ: |
| 98 | initial_event = event; |
| 99 | cancel_timeout(); |
| 100 | cache_action = nullptr; |
| 101 | cache_vc = static_cast<CacheVConnection *>(data); |
| 102 | buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K); |
| 103 | buffer_reader = buffer->alloc_reader(); |
| 104 | if (open_read_callout() < 0) { |
| 105 | goto Lclose_error_next; |
| 106 | } else { |
| 107 | return EVENT_DONE; |
| 108 | } |
| 109 | |
| 110 | case CACHE_EVENT_OPEN_READ_FAILED: |
| 111 | goto Lcancel_next; |
| 112 | |
| 113 | case VC_EVENT_READ_READY: |
| 114 | if (!check_buffer()) { |
| 115 | goto Lclose_error_next; |
| 116 | } |
| 117 | buffer_reader->consume(buffer_reader->read_avail()); |
| 118 | (static_cast<VIO *>(data))->reenable(); |
| 119 | return EVENT_CONT; |
| 120 | |
| 121 | case VC_EVENT_READ_COMPLETE: |
| 122 | if (!check_buffer()) { |
| 123 | goto Lclose_error_next; |
| 124 | } |
| 125 | goto Lclose_next; |
| 126 | |
| 127 | case VC_EVENT_ERROR: |
| 128 | case VC_EVENT_EOS: |
| 129 | goto Lclose_error_next; |
| 130 | |
| 131 | case CACHE_EVENT_OPEN_WRITE: |
nothing calls this directly
no test coverage detected