1 Star 0 Fork 12

靳智敏/ipmitool

forked from src-openEuler/ipmitool 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
open-checking-received-msg-id-against-expectation.patch 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:53 . Package init
From 51634fd77c836e3cb5acd9b9b72e7ede20321d56 Mon Sep 17 00:00:00 2001
From: Patrick Venture <venture@google.com>
Date: Tue, 4 Dec 2018 16:47:09 -0800
Subject: [PATCH 116/119] open: checking received msg id against expectation
Check the received IPMI response message id against
the id expected given the IPMI request. They need to
match. It is possible that request A times out,
request B is sent, and then request A responds to the
request B. The value for request B may be behind it
in the queue.
Note: This may only be possible if the file is kept
open between multiple IPMI messages (a common
occurrence).
Resolves: #82
Signed-off-by: Patrick Venture <venture@google.com>
---
src/plugins/open/open.c | 80 +++++++++++++++++++++++------------------
1 file changed, 46 insertions(+), 34 deletions(-)
diff --git a/src/plugins/open/open.c b/src/plugins/open/open.c
index 2235509..101676f 100644
--- a/src/plugins/open/open.c
+++ b/src/plugins/open/open.c
@@ -336,48 +336,60 @@ ipmi_openipmi_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT;
read_timeout.tv_usec = 0;
do {
- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
- } while (retval < 0 && errno == EINTR);
- if (retval < 0) {
- lperror(LOG_ERR, "I/O Error");
- if (data != NULL) {
- free(data);
+ do {
+ retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
+ } while (retval < 0 && errno == EINTR);
+ if (retval < 0) {
+ lperror(LOG_ERR, "I/O Error");
+ if (data != NULL) {
+ free(data);
data = NULL;
- }
- return NULL;
- } else if (retval == 0) {
- lprintf(LOG_ERR, "No data available");
- if (data != NULL) {
- free(data);
- data = NULL;
+ }
+ return NULL;
+ } else if (retval == 0) {
+ lprintf(LOG_ERR, "No data available");
+ if (data != NULL) {
+ free(data);
+ data = NULL;
+ }
+ return NULL;
}
- return NULL;
- }
- if (FD_ISSET(intf->fd, &rset) == 0) {
- lprintf(LOG_ERR, "No data available");
- if (data != NULL) {
- free(data);
+ if (FD_ISSET(intf->fd, &rset) == 0) {
+ lprintf(LOG_ERR, "No data available");
+ if (data != NULL) {
+ free(data);
data = NULL;
- }
- return NULL;
- }
+ }
+ return NULL;
+ }
- recv.addr = (unsigned char *) &addr;
- recv.addr_len = sizeof(addr);
- recv.msg.data = rsp.data;
- recv.msg.data_len = sizeof(rsp.data);
+ recv.addr = (unsigned char *) &addr;
+ recv.addr_len = sizeof(addr);
+ recv.msg.data = rsp.data;
+ recv.msg.data_len = sizeof(rsp.data);
- /* get data */
- if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
- lperror(LOG_ERR, "Error receiving message");
- if (errno != EMSGSIZE) {
- if (data != NULL) {
+ /* get data */
+ if (ioctl(intf->fd, IPMICTL_RECEIVE_MSG_TRUNC, &recv) < 0) {
+ lperror(LOG_ERR, "Error receiving message");
+ if (errno != EMSGSIZE) {
+ if (data != NULL) {
free(data);
data = NULL;
}
- return NULL;
- }
- }
+ return NULL;
+ }
+ }
+ /* If the message received wasn't expected, try to grab the
+ * next message until it's out of messages. -EAGAIN is
+ * returned if the list empty, but basically if it returns a
+ * message, check if it's alright.
+ */
+ if (_req.msgid != recv.msgid) {
+ lprintf(LOG_NOTICE,
+ "Received a response with unexpected ID %ld vs. %ld",
+ recv.msgid, _req.msgid);
+ }
+ } while (_req.msgid != recv.msgid);
if (verbose > 4) {
fprintf(stderr, "Got message:");
--
2.19.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jinzhimin369/ipmitool.git
git@gitee.com:jinzhimin369/ipmitool.git
jinzhimin369
ipmitool
ipmitool
master

搜索帮助