// If the request stack is full, destroy this one
// else put this one at the front of the request stack; we do this because
// we want the most-recently-used curl handle to be re-used on the next
// request, to maximize our chances of re-using a TCP connection before it
// times out
if (requestStackCountG == AOS_REQUEST_STACK_SIZE) {
apr_thread_mutex_unlock(requestStackMutexG);
curl_easy_cleanup(request);
}
else {
requestStackG[requestStackCountG++] = request;
apr_thread_mutex_unlock(requestStackMutexG);
}
when call aos_request_get, request will be reset to init status.
If we reset request before add to requestStackG, we can release unneed memory.
// related codes:
CURL aos_request_get() { CURL request = NULL;
}
void request_release(CURL *request) { apr_thread_mutex_lock(requestStackMutexG);
}