67 lines
2.6 KiB
Diff
67 lines
2.6 KiB
Diff
From 954c37acbb0a9a790d07b567ad99c952e150e6da Mon Sep 17 00:00:00 2001
|
||
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
||
Date: Tue, 27 Feb 2024 16:05:13 +0800
|
||
Subject: [PATCH 5/5] [PluginClient] Bugfix for semaphore exception and port
|
||
number release.
|
||
|
||
---
|
||
lib/PluginClient/PluginClient.cpp | 16 +++++++++++++---
|
||
lib/Translate/GimpleToPluginOps.cpp | 7 ++++++-
|
||
2 files changed, 19 insertions(+), 4 deletions(-)
|
||
|
||
diff --git a/lib/PluginClient/PluginClient.cpp b/lib/PluginClient/PluginClient.cpp
|
||
index fba0de4..6bc6401 100644
|
||
--- a/lib/PluginClient/PluginClient.cpp
|
||
+++ b/lib/PluginClient/PluginClient.cpp
|
||
@@ -1749,7 +1749,12 @@ static bool WaitServer(const string& port)
|
||
mode_t mask = umask(0);
|
||
mode_t mode = 0666; // 权限是rwrwrw,跨进程时,其他用户也要可以访问
|
||
string semFile = "wait_server_startup" + port;
|
||
- sem_t *sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
|
||
+ sem_t *sem = sem_open(semFile.c_str(), O_CREAT | O_EXCL, mode, 0);
|
||
+ // Semaphore exception handling.
|
||
+ if (sem == SEM_FAILED) {
|
||
+ sem_unlink(semFile.c_str());
|
||
+ sem = sem_open(semFile.c_str(), O_CREAT, mode, 0);
|
||
+ }
|
||
umask(mask);
|
||
int i = 0;
|
||
for (; i < cnt; i++) {
|
||
@@ -1770,8 +1775,13 @@ static bool WaitServer(const string& port)
|
||
int PluginClient::ServerStart(pid_t& pid)
|
||
{
|
||
if (!grpcPort.FindUnusedPort()) {
|
||
- LOGE("cannot find port for grpc,port 40001-65535 all used!\n");
|
||
- return -1;
|
||
+ // Rectify the fault that the port number is not released
|
||
+ // because the client is abnormal.
|
||
+ LOGW("cannot find port for grpc, try again!\n");
|
||
+ if (!grpcPort.FindUnusedPort()) {
|
||
+ LOGE("cannot find port for grpc,port 40001-65534 all used!\n");
|
||
+ return -1;
|
||
+ }
|
||
}
|
||
|
||
int ret = 0;
|
||
diff --git a/lib/Translate/GimpleToPluginOps.cpp b/lib/Translate/GimpleToPluginOps.cpp
|
||
index 342ef3d..76c5e31 100644
|
||
--- a/lib/Translate/GimpleToPluginOps.cpp
|
||
+++ b/lib/Translate/GimpleToPluginOps.cpp
|
||
@@ -1523,7 +1523,12 @@ Value GimpleToPluginOps::TreeToValue(uint64_t treeId)
|
||
unsigned HOST_WIDE_INT uinit = tree_to_uhwi(t);
|
||
initAttr = builder.getI64IntegerAttr(uinit);
|
||
} else {
|
||
- abort();
|
||
+ wide_int val = wi::to_wide(t);
|
||
+ if (wi::neg_p(val, TYPE_SIGN(TREE_TYPE(t)))) {
|
||
+ val = -val;
|
||
+ }
|
||
+ signed HOST_WIDE_INT init = val.to_shwi();
|
||
+ initAttr = builder.getI64IntegerAttr(init);
|
||
}
|
||
GetTreeAttr(treeId, readOnly, rPluginType);
|
||
opValue = builder.create<ConstOp>(
|
||
--
|
||
2.33.0
|
||
|