diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index b970b4b144878fe3a0ae8e812e64589e3441bfce..c82b67e228e626d20955dc40725cc7e25afb2da4 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -28,7 +28,8 @@ static int TrivalOpenRtgNode(void) { char fileName[] = "/proc/self/sched_rtg_ctrl"; - int fd = open(fileName, O_RDWR); + FILE* f = fopen(fileName, "w+"); + int fd = fileno(f); if (fd < 0) { CONCUR_LOGE("[Interface] task %{public}d belong to user %{public}d open rtg node failed, errno = %{public}d", getpid(), getuid(), errno); @@ -50,7 +51,8 @@ static int TrivalOpenAuthCtrlNode(void) static int TrivalOpenQosCtrlNode(void) { char fileName[] = "/proc/thread-self/sched_qos_ctrl"; - int fd = open(fileName, O_RDWR); + FILE* f = fopen(fileName, "w+"); + int fd = fileno(f); if (fd < 0) { CONCUR_LOGE("[Interface] task %{public}d belong to user %{public}d open qos node failed, errno = %{public}d", getpid(), getuid(), errno); @@ -77,8 +79,10 @@ int EnableRtg(bool flag) printf("set rtg config enable failed.\n"); } - close(fd); - + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return 0; }; @@ -258,7 +262,10 @@ int QosApplyForOther(unsigned int level, int tid) if (ret < 0) { CONCUR_LOGE("[Interface] task %{public}d apply qos failed, errno = %{public}d", tid, errno); } - close(fd); + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return ret; } @@ -280,7 +287,10 @@ int QosLeave(void) if (ret < 0) { CONCUR_LOGE("[Interface] task %{public}d leave qos failed, errno = %{public}d", gettid(), errno); } - close(fd); + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return ret; } @@ -302,7 +312,10 @@ int QosLeaveForOther(int tid) if (ret < 0) { CONCUR_LOGE("[Interface] task %{public}d leave qos failed, errno = %{public}d", tid, errno); } - close(fd); + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return ret; } @@ -320,7 +333,10 @@ int QosPolicySet(const struct QosPolicyDatas *policyDatas) if (ret < 0) { CONCUR_LOGE("[Interface] set qos policy failed, errno = %{public}d", errno); } - close(fd); + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return ret; } @@ -351,6 +367,9 @@ int QosGetForOther(int tid, int &level) } level = data.qos; - close(fd); + FILE* f = fdopen(fd, "w+"); + if (f != nullptr) { + fclose(f); + } return ret; } \ No newline at end of file