mirror of
https://github.com/openharmony/tools_previewer.git
synced 2026-07-19 14:23:32 -04:00
!96 websocket创建失败
Merge pull request !96 from fupengfei/OpenHarmony-4.0-Beta2
This commit is contained in:
@@ -180,5 +180,6 @@ int main(int argc, char* argv[])
|
||||
std::thread commandThead(ProcessCommand);
|
||||
commandThead.detach();
|
||||
InitJsApp();
|
||||
this_thread::sleep_for(chrono::milliseconds(500));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -190,5 +190,6 @@ int main(int argc, char* argv[])
|
||||
this_thread::sleep_for(chrono::milliseconds(1));
|
||||
}
|
||||
JsAppImpl::GetInstance().Stop();
|
||||
this_thread::sleep_for(chrono::milliseconds(500));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ export function generateClassDeclaration(rootName: string, classEntity: ClassEnt
|
||||
isExtend = true;
|
||||
classBody += `${value.clauseToken} `;
|
||||
value.types.forEach((val, index) => {
|
||||
const moduleName = firstCharacterToUppercase(rootName);
|
||||
if (classEntity.exportModifiers.includes(SyntaxKind.ExportKeyword) && rootName !== '') {
|
||||
val = `mock${moduleName}().${val}`;
|
||||
}
|
||||
if (index !== value.types.length - 1) {
|
||||
classBody += `${val},`;
|
||||
} else {
|
||||
|
||||
@@ -126,14 +126,9 @@ JsAppImpl& JsAppImpl::GetInstance()
|
||||
|
||||
void JsAppImpl::Start()
|
||||
{
|
||||
if (jsThread != nullptr) {
|
||||
delete jsThread;
|
||||
jsThread = nullptr;
|
||||
}
|
||||
|
||||
isFinished = false;
|
||||
isInterrupt = false;
|
||||
jsThread = new thread(&JsAppImpl::ThreadCallBack, &JsAppImpl::GetInstance());
|
||||
jsThread = std::make_unique<std::thread>(&JsAppImpl::ThreadCallBack, &JsAppImpl::GetInstance());
|
||||
if (jsThread == nullptr) {
|
||||
ELOG("JsApp::Start jsThread memory allocation failed");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
std::unique_ptr<CppTimer> deviceCheckTimer;
|
||||
std::unique_ptr<CppTimer> jsCheckTimer;
|
||||
std::unique_ptr<OHOS::ACELite::JSAbility> jsAbility;
|
||||
std::thread* jsThread;
|
||||
std::unique_ptr<std::thread> jsThread;
|
||||
|
||||
void ThreadCallBack();
|
||||
void InitTimer();
|
||||
|
||||
@@ -118,11 +118,8 @@ void WebSocketServer::StartWebsocketListening()
|
||||
|
||||
void WebSocketServer::Run()
|
||||
{
|
||||
if (serverThread != nullptr) {
|
||||
delete serverThread;
|
||||
serverThread = nullptr;
|
||||
}
|
||||
serverThread = new std::thread(&WebSocketServer::StartWebsocketListening, &WebSocketServer::GetInstance());
|
||||
serverThread = std::make_unique<std::thread>(&WebSocketServer::StartWebsocketListening,
|
||||
&WebSocketServer::GetInstance());
|
||||
if (serverThread == nullptr) {
|
||||
ELOG("WebSocketServer::Start serverThread memory allocation failed");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
WebSocketServer();
|
||||
virtual ~WebSocketServer();
|
||||
static void sigint_handler(int sig);
|
||||
std::thread* serverThread;
|
||||
std::unique_ptr<std::thread> serverThread;
|
||||
int serverPort;
|
||||
const char* serverHostname = "127.0.0.1";
|
||||
int websocketMaxConn = 1024;
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void *oldBacetrace[10] = { nullptr };
|
||||
static size_t oldSize = 0;
|
||||
|
||||
void CrashHandler::InitExceptionHandler()
|
||||
{
|
||||
if (signal(SIGSEGV, ApplicationCrashHandler) == SIG_ERR) {
|
||||
@@ -36,7 +39,23 @@ void CrashHandler::InitExceptionHandler()
|
||||
|
||||
void CrashHandler::ApplicationCrashHandler(int signal)
|
||||
{
|
||||
// get void*'s for all entries on the stack
|
||||
const uint32_t MAX_STACK_SIZE = 128;
|
||||
int len = 10;
|
||||
void *array[len];
|
||||
size_t size = backtrace(array, MAX_STACK_SIZE);
|
||||
bool isSame = true;
|
||||
if (oldSize == size) {
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
if (oldBacetrace[i] != array[i]) {
|
||||
isSame = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSame) {
|
||||
return;
|
||||
}
|
||||
// print crash log head
|
||||
int8_t crashBeginLog[] = "[JsEngine Crash]Engine Crash Info Begin.\n";
|
||||
write(STDERR_FILENO, crashBeginLog, sizeof(crashBeginLog) - 1);
|
||||
int8_t stackIntLog[PublicMethods::MAX_ITOA_BIT] = {0};
|
||||
@@ -44,13 +63,12 @@ void CrashHandler::ApplicationCrashHandler(int signal)
|
||||
int8_t signalLog[] = "[JsEngine Crash]Error: signal : 0x";
|
||||
write(STDERR_FILENO, signalLog, sizeof(signalLog) - 1);
|
||||
write(STDERR_FILENO, stackIntLog, itoaLength);
|
||||
|
||||
// get void*'s for all entries on the stack
|
||||
void *array[10];
|
||||
size_t size = backtrace(array, MAX_STACK_SIZE);
|
||||
// print out all the frames to stdout
|
||||
backtrace_symbols_fd(array, size, STDERR_FILENO);
|
||||
|
||||
std::fill(oldBacetrace, oldBacetrace + len, nullptr);
|
||||
std::copy(array, array + len, oldBacetrace);
|
||||
oldSize = size;
|
||||
// print crash log end
|
||||
int8_t crashEndLog[] = "\n[JsEngine Crash]Engine Crash Info End.\n";
|
||||
write(STDERR_FILENO, crashEndLog, sizeof(crashEndLog) - 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user