Revert threading changes, disable curl code for now.

This commit is contained in:
Steven Smith 2018-02-06 12:16:24 -08:00
parent 1539c55ec5
commit 2c982d85ec
11 changed files with 43 additions and 57 deletions

View File

@ -182,7 +182,7 @@ Result task_capture_cam(capture_cam_data* data) {
internalData->qrContext = quirc_new();
if(internalData->qrContext != NULL && quirc_resize(internalData->qrContext, data->width, data->height) == 0) {
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY)) && R_SUCCEEDED(res = svcCreateMutex(&data->mutex, false))) {
if(threadCreate(task_capture_cam_thread, internalData, 0x10000, 0x1A, 0, true) == NULL) {
if(threadCreate(task_capture_cam_thread, internalData, 0x10000, 0x1A, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -114,9 +114,7 @@ Result init_services() {
return res;
}
//static u32 old_time_limit = UINT32_MAX;
FILE* dbg;
static u32 old_time_limit = UINT32_MAX;
void init() {
gfxInitDefault();
@ -140,17 +138,17 @@ void init() {
}
}
/*APT_GetAppCpuTimeLimit(&old_time_limit);
osSetSpeedupEnable(true);
APT_GetAppCpuTimeLimit(&old_time_limit);
Result cpuRes = APT_SetAppCpuTimeLimit(30);
if(R_FAILED(cpuRes)) {
util_panic("Failed to set syscore CPU time limit: %08lX", cpuRes);
return;
}*/
}
AM_InitializeExternalTitleDatabase(false);
dbg = fopen("sdmc:/debug.txt", "wb");
curl_global_init(CURL_GLOBAL_ALL);
screen_init();
@ -160,17 +158,17 @@ void init() {
}
void cleanup() {
fclose(dbg);
clipboard_clear();
task_exit();
ui_exit();
screen_exit();
/*if(old_time_limit != UINT32_MAX) {
if(old_time_limit != UINT32_MAX) {
APT_SetAppCpuTimeLimit(old_time_limit);
}*/
}
osSetSpeedupEnable(false);
cleanup_services();
@ -179,44 +177,17 @@ void cleanup() {
gfxExit();
}
static void main_thread(void* arg) {
int main(int argc, const char* argv[]) {
if(argc > 0 && envIsHomebrew()) {
util_set_3dsx_path(argv[0]);
}
init();
mainmenu_open();
while(aptMainLoop() && ui_update());
cleanup();
}
int main(int argc, const char* argv[]) {
if(argc > 0 && envIsHomebrew()) {
util_set_3dsx_path(argv[0]);
}
osSetSpeedupEnable(true);
u32 oldTimeLimit = UINT32_MAX;
APT_GetAppCpuTimeLimit(&oldTimeLimit);
Result cpuRes = APT_SetAppCpuTimeLimit(30);
if(R_FAILED(cpuRes)) {
util_panic("Failed to set syscore CPU time limit: %08lX", cpuRes);
return 0;
}
Thread mainThread = threadCreate(main_thread, NULL, 0x10000, 0x18, 1, true);
if(mainThread == NULL) {
util_panic("Failed to start main thread.");
return 0;
}
threadJoin(mainThread, U64_MAX);
if(oldTimeLimit != UINT32_MAX) {
APT_SetAppCpuTimeLimit(oldTimeLimit);
}
osSetSpeedupEnable(false);
return 0;
}

View File

@ -451,9 +451,13 @@ void action_install_url(const char* confirmMessage, const char* urls, const char
data->installInfo.data = data;
#ifdef USE_CURL
data->installInfo.op = DATAOP_DOWNLOAD;
data->installInfo.downloadUrls = data->urls;
#else
data->installInfo.op = DATAOP_COPY;
#endif
data->installInfo.bufferSize = 128 * 1024;
data->installInfo.copyEmpty = false;

View File

@ -151,8 +151,6 @@ static Result task_data_op_copy(data_op_data* data, u32 index) {
return res;
}
extern FILE* dbg;
static Result task_download_execute(const char* url, void* data, size_t write_callback(char* ptr, size_t size, size_t nmemb, void* userdata),
int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)) {
Result res = 0;
@ -175,9 +173,6 @@ static Result task_download_execute(const char* url, void* data, size_t write_ca
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); // TODO: Certificates?
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
curl_easy_setopt(curl, CURLOPT_STDERR, dbg);
CURLcode ret = curl_easy_perform(curl);
if(ret == CURLE_OK) {
long responseCode;
@ -219,6 +214,7 @@ static size_t task_download_sync_write_callback(char* ptr, size_t size, size_t n
}
Result task_download_sync(const char* url, u32* downloadedSize, void* buf, size_t size) {
#ifdef USE_CURL
if(url == NULL || buf == NULL) {
return R_FBI_INVALID_ARGUMENT;
}
@ -233,6 +229,21 @@ Result task_download_sync(const char* url, u32* downloadedSize, void* buf, size_
}
return res;
#else
Result res = 0;
httpcContext context;
if(R_SUCCEEDED(res = util_http_open(&context, url, true))) {
res = util_http_read(&context, downloadedSize, buf, size);
Result closeRes = util_http_close(&context);
if(R_SUCCEEDED(res)) {
res = closeRes;
}
}
return res;
#endif
}
Result task_download_json_sync(const char* url, json_t** json, size_t maxSize) {
@ -548,7 +559,7 @@ Result task_data_op(data_op_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_data_op_thread, data, 0x10000, 0x18, 0, true) == NULL) {
if(threadCreate(task_data_op_thread, data, 0x10000, 0x18, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -160,7 +160,7 @@ Result task_populate_ext_save_data(populate_ext_save_data_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_ext_save_data_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_ext_save_data_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -317,7 +317,7 @@ Result task_populate_files(populate_files_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_files_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_files_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -138,7 +138,7 @@ Result task_populate_pending_titles(populate_pending_titles_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_pending_titles_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_pending_titles_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -106,7 +106,7 @@ Result task_populate_system_save_data(populate_system_save_data_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_system_save_data_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_system_save_data_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -133,7 +133,7 @@ Result task_populate_tickets(populate_tickets_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_tickets_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_tickets_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -275,7 +275,7 @@ Result task_populate_titledb(populate_titledb_data* data) {
if(R_SUCCEEDED(res = svcCreateEvent(&data->resumeEvent, RESET_STICKY))) {
svcSignalEvent(data->resumeEvent);
if(threadCreate(task_populate_titledb_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_titledb_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}

View File

@ -338,7 +338,7 @@ Result task_populate_titles(populate_titles_data* data) {
Result res = 0;
if(R_SUCCEEDED(res = svcCreateEvent(&data->cancelEvent, RESET_STICKY))) {
if(threadCreate(task_populate_titles_thread, data, 0x10000, 0x19, 0, true) == NULL) {
if(threadCreate(task_populate_titles_thread, data, 0x10000, 0x19, 1, true) == NULL) {
res = R_FBI_THREAD_CREATE_FAILED;
}
}