!120 增强libuv维测能力

Merge pull request !120 from Forever/commit
This commit is contained in:
openharmony_ci 2024-04-17 08:19:29 +00:00 committed by Gitee
commit 2eb1dadab2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 24 additions and 11 deletions

View File

@ -185,11 +185,10 @@ extern "C" {
#ifdef PRINT_ERRNO_ABORT
#include "info/fatal_message.h"
#define UV_ERRNO_ABORT(errno) \
#define UV_ERRNO_ABORT(...) \
do { \
char errno_message[1024]; \
snprintf(errno_message, sizeof(errno_message), \
"errno is %d (%s: %s: %d)", errno, __FILE__, __func__, __LINE__); \
snprintf(errno_message, sizeof(errno_message), __VA_ARGS__); \
set_fatal_message(errno_message); \
abort(); \
} while(0)

View File

@ -25,6 +25,7 @@
#include "uv.h"
#include "internal.h"
#include "atomic-ops.h"
#include "uv_log.h"
#include <errno.h>
#include <stdio.h> /* snprintf() */
@ -107,7 +108,8 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
continue;
#ifdef PRINT_ERRNO_ABORT
UV_ERRNO_ABORT(errno);
UV_ERRNO_ABORT("errno is %d, loop addr is %zu, fd is %d (%s:%s:%d)",
errno, (size_t)loop, w->fd, __FILE__, __func__, __LINE__);
#else
abort();
#endif
@ -164,7 +166,8 @@ static void uv__async_send(uv_async_t* handle) {
return;
#ifdef PRINT_ERRNO_ABORT
UV_ERRNO_ABORT(errno);
UV_ERRNO_ABORT("errno is %d, loop addr is %zu, fd is %d (%s:%s:%d)",
errno, (size_t)loop, fd, __FILE__, __func__, __LINE__);
#else
abort();
#endif
@ -194,7 +197,8 @@ static int uv__async_start(uv_loop_t* loop) {
uv__io_init(&loop->async_io_watcher, uv__async_io, pipefd[0]);
uv__io_start(loop, &loop->async_io_watcher, POLLIN);
loop->async_wfd = pipefd[1];
UV_LOGI("open: loop addr is %{public}zu, loop->async_wfd is %{public}d,"
"loop->async_io_watcher.fd is %{public}d", (size_t)loop, loop->async_wfd, pipefd[0]);
return 0;
}
@ -214,12 +218,16 @@ void uv__async_stop(uv_loop_t* loop) {
return;
if (loop->async_wfd != -1) {
if (loop->async_wfd != loop->async_io_watcher.fd)
if (loop->async_wfd != loop->async_io_watcher.fd) {
uv__close(loop->async_wfd);
UV_LOGI("close: loop addr is %{public}zu, loop->async_wfd is %{public}d", (size_t)loop, loop->async_wfd);
}
loop->async_wfd = -1;
}
uv__io_stop(loop, &loop->async_io_watcher, POLLIN);
uv__close(loop->async_io_watcher.fd);
UV_LOGI("close: loop addr is %{public}zu, loop->async_io_watcher.fd is %{public}d",
(size_t)loop, loop->async_io_watcher.fd);
loop->async_io_watcher.fd = -1;
}

View File

@ -20,6 +20,7 @@
*/
#include "uv.h"
#include "uv_log.h"
#include "internal.h"
#include <errno.h>
#include <sys/epoll.h>
@ -164,7 +165,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
if (errno != EEXIST)
#ifdef PRINT_ERRNO_ABORT
UV_ERRNO_ABORT(errno);
UV_ERRNO_ABORT("errno is %d, loop addr is %zu, backend_fd is %d, fd is %d (%s:%s:%d)",
errno, (size_t)loop, loop->backend_fd, w->fd, __FILE__, __func__, __LINE__);
#else
abort();
#endif
@ -174,7 +176,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
/* We've reactivated a file descriptor that's been watched before. */
if (epoll_ctl(loop->backend_fd, EPOLL_CTL_MOD, w->fd, &e))
#ifdef PRINT_ERRNO_ABORT
UV_ERRNO_ABORT(errno);
UV_ERRNO_ABORT("errno is %d, loop addr is %zu, backend_fd is %d, fd is %d (%s:%s:%d)",
errno, (size_t)loop, loop->backend_fd, w->fd, __FILE__, __func__, __LINE__);
#else
abort();
#endif
@ -290,7 +293,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (errno != EINTR)
#ifdef PRINT_ERRNO_ABORT
UV_ERRNO_ABORT(errno);
UV_ERRNO_ABORT("errno is %d, loop addr is %zu, backend_fd is %d (%s:%s:%d)",
errno, (size_t)loop, loop->backend_fd, __FILE__, __func__, __LINE__);
#else
abort();
#endif

View File

@ -21,6 +21,7 @@
#include "uv.h"
#include "uv/tree.h"
#include "uv_log.h"
#include "internal.h"
#include "heap-inl.h"
#include <stdlib.h>
@ -32,7 +33,7 @@ int uv_loop_init(uv_loop_t* loop) {
void* saved_data;
int err;
UV_LOGI("loop init: loop addr is %{public}zu", (size_t)loop);
saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
loop->data = saved_data;
@ -184,6 +185,7 @@ void uv__loop_close(uv_loop_t* loop) {
if (loop->backend_fd != -1) {
uv__close(loop->backend_fd);
UV_LOGI("close: loop addr is %{public}zu, loop->backend_fd is %{public}d", (size_t)loop, loop->backend_fd);
loop->backend_fd = -1;
}