Fix a ref count mistake and add a long-overdue tf_util_print_backtrace() that helped me find it.
This commit is contained in:
parent
9de8b0f449
commit
410bb7c09d
@ -1019,7 +1019,7 @@ void tf_http_request_unref(tf_http_request_t* request)
|
||||
tf_free(request);
|
||||
}
|
||||
|
||||
if (--connection->ref_count == 0)
|
||||
if (connection && --connection->ref_count == 0)
|
||||
{
|
||||
if (connection->http->is_shutting_down)
|
||||
{
|
||||
|
@ -1541,7 +1541,6 @@ static void _httpd_endpoint_login_work(tf_ssb_t* ssb, void* user_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
tf_http_request_ref(request);
|
||||
|
||||
login->name = account_name_copy;
|
||||
login->error = login_error;
|
||||
@ -1566,6 +1565,7 @@ static void _httpd_endpoint_login_work(tf_ssb_t* ssb, void* user_data)
|
||||
}
|
||||
|
||||
login->pending++;
|
||||
tf_http_request_ref(request);
|
||||
tf_file_read(login->request->user_data, "core/auth.html", _httpd_endpoint_login_file_read_callback, login);
|
||||
|
||||
account_name_copy = NULL;
|
||||
@ -1584,9 +1584,9 @@ done:
|
||||
static void _httpd_endpoint_login_after_work(tf_ssb_t* ssb, int status, void* user_data)
|
||||
{
|
||||
login_request_t* login = user_data;
|
||||
tf_http_request_t* request = login->request;
|
||||
if (login->pending == 1)
|
||||
{
|
||||
tf_http_request_t* request = login->request;
|
||||
if (*login->location_header)
|
||||
{
|
||||
const char* headers[] = {
|
||||
@ -1597,8 +1597,8 @@ static void _httpd_endpoint_login_after_work(tf_ssb_t* ssb, int status, void* us
|
||||
};
|
||||
tf_http_respond(request, 303, headers, tf_countof(headers) / 2, NULL, 0);
|
||||
}
|
||||
tf_http_request_unref(request);
|
||||
}
|
||||
tf_http_request_unref(request);
|
||||
_login_release(login);
|
||||
}
|
||||
|
||||
|
@ -435,6 +435,13 @@ const char* tf_util_backtrace_string()
|
||||
return tf_util_backtrace_to_string(buffer, count);
|
||||
}
|
||||
|
||||
void tf_util_print_backtrace()
|
||||
{
|
||||
const char* bt = tf_util_backtrace_string();
|
||||
tf_printf("%s\n", bt);
|
||||
tf_free((void*)bt);
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
typedef struct _android_backtrace_t
|
||||
{
|
||||
|
@ -126,6 +126,11 @@ const char* tf_util_backtrace_to_string(void* const* buffer, int count);
|
||||
*/
|
||||
const char* tf_util_backtrace_string();
|
||||
|
||||
/**
|
||||
** Print a stack backtrace of the calling thread.
|
||||
*/
|
||||
void tf_util_print_backtrace();
|
||||
|
||||
/**
|
||||
** Convert a function pointer to its name, if possible.
|
||||
** @return The function name or null.
|
||||
|
Loading…
Reference in New Issue
Block a user