mirror of
https://gitee.com/openharmony/third_party_libuv
synced 2025-01-14 00:30:53 +00:00
commit
Signed-off-by: yongyuan <fuyongyuan1@huawei.com>
This commit is contained in:
parent
838adeaa2f
commit
60479bd7f3
@ -28,6 +28,33 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef USE_FFRT
|
||||
#include <sys/types.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
static void uv__get_process_name(char* processName, int bufferLength) {
|
||||
int fd = open("/proc/self/cmdline", O_RDONLY);
|
||||
if (fd != -1) {
|
||||
ssize_t ret = syscall(SYS_read, fd, processName, bufferLength - 1);
|
||||
if (ret != -1) {
|
||||
processName[ret] = '\0';
|
||||
}
|
||||
syscall(SYS_close, fd);
|
||||
}
|
||||
}
|
||||
|
||||
static void uv__set_signal_flag(uv__loop_internal_fields_t* lfields) {
|
||||
char processName[1024] = {0};
|
||||
uv__get_process_name(processName, sizeof(processName));
|
||||
char* c = strstr(processName, "com.atomicservice.");
|
||||
if (c == NULL || c > processName) {
|
||||
lfields->trigger = 0;
|
||||
return;
|
||||
}
|
||||
lfields->trigger = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int uv_loop_init(uv_loop_t* loop) {
|
||||
uv__loop_internal_fields_t* lfields;
|
||||
void* saved_data;
|
||||
@ -42,7 +69,9 @@ int uv_loop_init(uv_loop_t* loop) {
|
||||
if (lfields == NULL)
|
||||
return UV_ENOMEM;
|
||||
loop->internal_fields = lfields;
|
||||
|
||||
#ifdef USE_FFRT
|
||||
uv__set_signal_flag(lfields);
|
||||
#endif
|
||||
err = uv_mutex_init(&lfields->loop_metrics.lock);
|
||||
if (err)
|
||||
goto fail_metrics_mutex_init;
|
||||
|
@ -507,7 +507,14 @@ static void uv__signal_event(uv_loop_t* loop,
|
||||
|
||||
if (msg->signum == handle->signum) {
|
||||
assert(!(handle->flags & UV_HANDLE_CLOSING));
|
||||
#ifdef USE_FFRT
|
||||
uv__loop_internal_fields_t* lfields = uv__get_internal_fields(handle->loop);
|
||||
if (lfields->trigger != 1) {
|
||||
handle->signal_cb(handle, handle->signum);
|
||||
}
|
||||
#else
|
||||
handle->signal_cb(handle, handle->signum);
|
||||
#endif
|
||||
}
|
||||
|
||||
handle->dispatched_signals++;
|
||||
|
@ -449,6 +449,7 @@ struct uv__loop_internal_fields_s {
|
||||
#endif /* __linux__ */
|
||||
#ifdef USE_FFRT
|
||||
struct uv__queue wq_sub[4];
|
||||
unsigned int trigger;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user