////////////////////////////////////////////////////////////////////////// Name : handle_cache_write_lock Description: Details : Possible Next States From Here: - result of how_to_open_connection //////////////////////////////////////////////////////////////////////////
| 3135 | // |
| 3136 | /////////////////////////////////////////////////////////////////////////////// |
| 3137 | void |
| 3138 | HttpTransact::handle_cache_write_lock(State *s) |
| 3139 | { |
| 3140 | bool remove_ims = false; |
| 3141 | |
| 3142 | ink_assert(s->cache_info.action == CACHE_PREPARE_TO_DELETE || s->cache_info.action == CACHE_PREPARE_TO_UPDATE || |
| 3143 | s->cache_info.action == CACHE_PREPARE_TO_WRITE); |
| 3144 | |
| 3145 | switch (s->cache_info.write_lock_state) { |
| 3146 | case CACHE_WL_SUCCESS: |
| 3147 | // We were able to get the lock for the URL vector in the cache |
| 3148 | SET_UNPREPARE_CACHE_ACTION(s->cache_info); |
| 3149 | break; |
| 3150 | case CACHE_WL_FAIL: |
| 3151 | // No write lock, ignore the cache and proxy only; |
| 3152 | // FIX: Should just serve from cache if this is a revalidate |
| 3153 | Metrics::Counter::increment(http_rsb.cache_open_write_fail_count); |
| 3154 | s->cache_info.action = CACHE_DO_NO_ACTION; |
| 3155 | switch (s->cache_open_write_fail_action) { |
| 3156 | case CACHE_WL_FAIL_ACTION_ERROR_ON_MISS: |
| 3157 | case CACHE_WL_FAIL_ACTION_ERROR_ON_MISS_STALE_ON_REVALIDATE: |
| 3158 | case CACHE_WL_FAIL_ACTION_ERROR_ON_MISS_OR_REVALIDATE: |
| 3159 | TxnDbg(dbg_ctl_http_error, "cache_open_write_fail_action %d, cache miss, return error", s->cache_open_write_fail_action); |
| 3160 | s->cache_info.write_status = CACHE_WRITE_ERROR; |
| 3161 | build_error_response(s, HTTP_STATUS_BAD_GATEWAY, "Connection Failed", "connect#failed_connect"); |
| 3162 | MIMEField *ats_field; |
| 3163 | HTTPHdr *header; |
| 3164 | header = &(s->hdr_info.client_response); |
| 3165 | if ((ats_field = header->field_find(MIME_FIELD_ATS_INTERNAL, MIME_LEN_ATS_INTERNAL)) == nullptr) { |
| 3166 | if (likely((ats_field = header->field_create(MIME_FIELD_ATS_INTERNAL, MIME_LEN_ATS_INTERNAL)) != nullptr)) { |
| 3167 | header->field_attach(ats_field); |
| 3168 | } |
| 3169 | } |
| 3170 | if (likely(ats_field)) { |
| 3171 | int value = (s->cache_info.object_read) ? 1 : 0; |
| 3172 | TxnDbg(dbg_ctl_http_error, "Adding Ats-Internal-Messages: %d", value); |
| 3173 | header->field_value_set_int(ats_field, value); |
| 3174 | } else { |
| 3175 | TxnDbg(dbg_ctl_http_error, "failed to add Ats-Internal-Messages"); |
| 3176 | } |
| 3177 | |
| 3178 | TRANSACT_RETURN(SM_ACTION_SEND_ERROR_CACHE_NOOP, nullptr); |
| 3179 | default: |
| 3180 | s->cache_info.write_status = CACHE_WRITE_LOCK_MISS; |
| 3181 | remove_ims = true; |
| 3182 | break; |
| 3183 | } |
| 3184 | break; |
| 3185 | case CACHE_WL_READ_RETRY: |
| 3186 | s->request_sent_time = UNDEFINED_TIME; |
| 3187 | s->response_received_time = UNDEFINED_TIME; |
| 3188 | s->cache_info.action = CACHE_DO_LOOKUP; |
| 3189 | if (!s->cache_info.object_read) { |
| 3190 | // Write failed and read retry triggered |
| 3191 | // Clean up server_request and re-initiate |
| 3192 | // Cache Lookup |
| 3193 | ink_assert(s->cache_open_write_fail_action == CACHE_WL_FAIL_ACTION_READ_RETRY); |
| 3194 | s->cache_info.write_status = CACHE_WRITE_LOCK_MISS; |
nothing calls this directly
no test coverage detected