@@ -3162,6 +3162,16 @@ tfw_http_resp_cache_cb(TfwHttpMsg *msg)
3162
3162
TfwHttpReq * req = resp -> req ;
3163
3163
3164
3164
TFW_DBG2 ("%s: req = %p, resp = %p\n" , __func__ , req , resp );
3165
+ /*
3166
+ * Response will never be sent: client has disconnected already.
3167
+ * Don't adjust response, simply destroy it.
3168
+ */
3169
+ if (unlikely (test_bit (TFW_HTTP_B_REQ_DROP , req -> flags ))) {
3170
+ TFW_DBG2 ("%s: resp=[%p] dropped: client disconnected\n" ,
3171
+ __func__ , resp );
3172
+ tfw_http_resp_pair_free (req );
3173
+ return ;
3174
+ }
3165
3175
/*
3166
3176
* Typically we're at a node far from the node where @resp was
3167
3177
* received, so we do an inter-node transfer. However, this is
@@ -3171,26 +3181,11 @@ tfw_http_resp_cache_cb(TfwHttpMsg *msg)
3171
3181
*/
3172
3182
if (tfw_http_adjust_resp (resp )) {
3173
3183
tfw_http_conn_msg_free ((TfwHttpMsg * )resp );
3174
- tfw_http_send_resp (req , 500 , "response dropped:"
3175
- " processing error" );
3184
+ tfw_http_send_resp (req , 500 ,
3185
+ "response dropped: processing error" );
3176
3186
TFW_INC_STAT_BH (serv .msgs_otherr );
3177
3187
return ;
3178
3188
}
3179
- /*
3180
- * Responses from cache don't have @resp->conn. Also, for those
3181
- * responses @req->jtxtstamp is not set and remains zero.
3182
- *
3183
- * TODO: Currently APM holds the pure roundtrip time (RTT) from
3184
- * the time a request is forwarded to the time a response to it
3185
- * is received and parsed. Perhaps it makes sense to penalize
3186
- * server connections which get broken too often. What would be
3187
- * a fast and simple algorithm for that? Keep in mind, that the
3188
- * value of RTT has an upper boundary in the APM.
3189
- */
3190
- if (resp -> conn )
3191
- tfw_apm_update (((TfwServer * )resp -> conn -> peer )-> apmref ,
3192
- resp -> jrxtstamp ,
3193
- resp -> jrxtstamp - req -> jtxtstamp );
3194
3189
tfw_http_resp_fwd (resp );
3195
3190
}
3196
3191
@@ -3290,6 +3285,7 @@ tfw_http_resp_gfsm(TfwHttpMsg *hmresp, TfwFsmData *data)
3290
3285
static int
3291
3286
tfw_http_resp_cache (TfwHttpMsg * hmresp )
3292
3287
{
3288
+ TfwHttpResp * resp = (TfwHttpResp * )hmresp ;
3293
3289
TfwHttpReq * req = hmresp -> req ;
3294
3290
TfwFsmData data ;
3295
3291
time_t timestamp = tfw_current_timestamp ();
@@ -3299,7 +3295,7 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
3299
3295
* for age calculations, and for APM and Load Balancing.
3300
3296
*/
3301
3297
hmresp -> cache_ctl .timestamp = timestamp ;
3302
- (( TfwHttpResp * ) hmresp ) -> jrxtstamp = jiffies ;
3298
+ resp -> jrxtstamp = jiffies ;
3303
3299
/*
3304
3300
* If 'Date:' header is missing in the response, then
3305
3301
* set the date to the time the response was received.
@@ -3311,6 +3307,16 @@ tfw_http_resp_cache(TfwHttpMsg *hmresp)
3311
3307
* fwd_queue.
3312
3308
*/
3313
3309
tfw_http_popreq (hmresp , true);
3310
+ /*
3311
+ * TODO: Currently APM holds the pure roundtrip time (RTT) from
3312
+ * the time a request is forwarded to the time a response to it
3313
+ * is received and parsed. Perhaps it makes sense to penalize
3314
+ * server connections which get broken too often. What would be
3315
+ * a fast and simple algorithm for that? Keep in mind, that the
3316
+ * value of RTT has an upper boundary in the APM.
3317
+ */
3318
+ tfw_apm_update (((TfwServer * )resp -> conn -> peer )-> apmref ,
3319
+ resp -> jrxtstamp , resp -> jrxtstamp - req -> jtxtstamp );
3314
3320
/*
3315
3321
* Health monitor request means that its response need not to
3316
3322
* send anywhere.
0 commit comments