2023-07-27 12:26:54 +00:00
|
|
|
diff -up ipmitool-1.8.18/src/plugins/open/open.c.checking-received ipmitool-1.8.18/src/plugins/open/open.c
|
|
|
|
--- ipmitool-1.8.18/src/plugins/open/open.c.checking-received 2023-07-25 17:14:22.112985375 +0200
|
|
|
|
+++ ipmitool-1.8.18/src/plugins/open/open.c 2023-07-25 17:14:22.115985324 +0200
|
|
|
|
@@ -336,48 +336,61 @@ ipmi_openipmi_send_cmd(struct ipmi_intf
|
2023-07-27 11:53:07 +00:00
|
|
|
read_timeout.tv_sec = IPMI_OPENIPMI_READ_TIMEOUT;
|
|
|
|
read_timeout.tv_usec = 0;
|
|
|
|
do {
|
2023-07-27 11:56:58 +00:00
|
|
|
- retval = select(intf->fd+1, &rset, NULL, NULL, &read_timeout);
|
2023-07-27 11:53:07 +00:00
|
|
|
- } while (retval < 0 && errno == EINTR);
|
|
|
|
- if (retval < 0) {
|
2023-07-27 12:26:54 +00:00
|
|
|
- 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;
|
2023-07-27 11:53:07 +00:00
|
|
|
- } else if (retval == 0) {
|
|
|
|
- lprintf(LOG_ERR, "No data available");
|
2023-07-27 11:56:58 +00:00
|
|
|
- if (data != NULL) {
|
2023-07-27 11:53:07 +00:00
|
|
|
- free(data);
|
|
|
|
- data = NULL;
|
|
|
|
- }
|
|
|
|
- return NULL;
|
|
|
|
- }
|
|
|
|
- if (FD_ISSET(intf->fd, &rset) == 0) {
|
2023-07-27 12:26:54 +00:00
|
|
|
- lprintf(LOG_ERR, "No data available");
|
|
|
|
- if (data != NULL) {
|
|
|
|
- free(data);
|
2023-07-27 11:53:07 +00:00
|
|
|
+ }
|
|
|
|
+ return NULL;
|
|
|
|
+ } else if (retval == 0) {
|
|
|
|
+ lprintf(LOG_ERR, "No data available");
|
2023-07-27 11:56:58 +00:00
|
|
|
+ if (data != NULL) {
|
2023-07-27 11:53:07 +00:00
|
|
|
+ free(data);
|
2023-07-27 12:26:54 +00:00
|
|
|
data = NULL;
|
2023-07-27 11:53:07 +00:00
|
|
|
+ }
|
|
|
|
+ return NULL;
|
2023-07-27 12:26:54 +00:00
|
|
|
}
|
|
|
|
- return NULL;
|
2023-07-27 11:53:07 +00:00
|
|
|
- }
|
|
|
|
-
|
2023-07-27 11:56:58 +00:00
|
|
|
- recv.addr = (unsigned char *) &addr;
|
2023-07-27 11:53:07 +00:00
|
|
|
- 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) {
|
2023-07-27 12:26:54 +00:00
|
|
|
- lperror(LOG_ERR, "Error receiving message");
|
|
|
|
- if (errno != EMSGSIZE) {
|
2023-07-27 11:53:07 +00:00
|
|
|
+ if (FD_ISSET(intf->fd, &rset) == 0) {
|
|
|
|
+ lprintf(LOG_ERR, "No data available");
|
2023-07-27 12:26:54 +00:00
|
|
|
if (data != NULL) {
|
|
|
|
free(data);
|
|
|
|
data = NULL;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-07-27 11:53:07 +00:00
|
|
|
- }
|
|
|
|
+
|
|
|
|
+ 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) {
|
2023-07-27 11:56:58 +00:00
|
|
|
+ if (data != NULL) {
|
2023-07-27 11:53:07 +00:00
|
|
|
+ free(data);
|
|
|
|
+ data = 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) {
|
2023-07-27 12:26:54 +00:00
|
|
|
fprintf(stderr, "Got message:");
|