Skip to contentSkip to conversation

dtprobed: fix dof_stash write failure handling

PATCH In review Kris Van Hees 2 participants 2 messages Aug 28 – Aug 29

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 dtprobed: fix dof_stash write failure handling

Use ssize_t for write() results, retry interrupted writes without treating the negative length as progress, and unwind through the provider-close path if writing parsed DOF fails. Replace the no-op assert(1) in the corrupt-state path with abort().

---
 dtprobed/dof_stash.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
dtprobed/dof_stash.c +9 -5
index 6e62bdf6..144cc98d 100644
@@ -420,10 +420,14 @@ write_chunk(int fd, const void *buf, size_t size)
 	char *bufptr = (char *) buf;
 
 	while (size > 0) {
-		size_t len;
+		ssize_t len;
 
-		if ((len = write(fd, bufptr, size)) < 0 && errno != EINTR)
-			return -1;
+		if ((len = write(fd, bufptr, size)) < 0) {
+			if (errno != EINTR)
+				return -1;
+			else
+				continue;
+		}
 
 		size -= len;
 		bufptr += len;
@@ -796,7 +800,7 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)
 			state = accump->parsed->type;
 
 			if (write_chunk(parsed_fd, accump->parsed, accump->parsed->size) < 0)
-				goto err_probe_link;
+				goto err_provider_close;
 			break;
 
 		/* Error return from parser.  */
@@ -817,7 +821,7 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)
 			 */
 			fuse_log(FUSE_LOG_ERR, "dtprobed: PID %i, %lx/%lx: internal error: corrupt parsed DOF: type %i\n",
 				 pid, dev, ino, accump->parsed->type);
-			assert(1);
+			abort();
 		}
 
 		free(parsedfn);
Signature · 1 line
2.52.0
Reviewed-by on v1 6/6
#1 lore raw
Quoted 7 lines · Kris Van Hees via DTrace-devel

Use ssize_t for write() results, retry interrupted writes without treating the negative length as progress, and unwind through the provider-close path if writing parsed DOF fails. Replace the no-op assert(1) in the corrupt-state path with abort().

Took a while to make sense of that dof_stash_write_parsed(), but

Quoted 53 lines
---
 dtprobed/dof_stash.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
dtprobed/dof_stash.c +9 -5
index 6e62bdf6..144cc98d 100644
@@ -420,10 +420,14 @@ write_chunk(int fd, const void *buf, size_t size)
 	char *bufptr = (char *) buf;
 
 	while (size > 0) {
-		size_t len;
+		ssize_t len;
 
-		if ((len = write(fd, bufptr, size)) < 0 && errno != EINTR)
-			return -1;
+		if ((len = write(fd, bufptr, size)) < 0) {
+			if (errno != EINTR)
+				return -1;
+			else
+				continue;
+		}
 
 		size -= len;
 		bufptr += len;
@@ -796,7 +800,7 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)
 			state = accump->parsed->type;
 
 			if (write_chunk(parsed_fd, accump->parsed, accump->parsed->size) < 0)
-				goto err_probe_link;
+				goto err_provider_close;
 			break;
 
 		/* Error return from parser.  */
@@ -817,7 +821,7 @@ dof_stash_write_parsed(pid_t pid, dev_t dev, ino_t ino, dt_list_t *accum)
 			 */
 			fuse_log(FUSE_LOG_ERR, "dtprobed: PID %i, %lx/%lx: internal error: corrupt parsed DOF: type %i\n",
 				 pid, dev, ino, accump->parsed->type);
-			assert(1);
+			abort();
 		}
 
 		free(parsedfn);
Signature · 7 lines
2.52.0


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel