ed999124da
Fix some ifdef mess in sysdeps/bsd/procmem.c. Fix some warnings and implicit references. Fix subnet display. Bring a couple of patches from FreeBSD. This is still not perfect but libgtop2 is now much more robust.
62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
$OpenBSD: patch-src_daemon_io_c,v 1.4 2010/04/08 15:57:46 ajacoutot Exp $
|
|
|
|
From FreeBSD.
|
|
|
|
--- src/daemon/io.c.orig Sun Apr 19 19:51:00 2009
|
|
+++ src/daemon/io.c Fri Apr 2 10:51:08 2010
|
|
@@ -20,6 +20,7 @@
|
|
*/
|
|
|
|
#include <config.h>
|
|
+#include <errno.h>
|
|
#include "daemon.h"
|
|
#include <glibtop/error.h>
|
|
|
|
@@ -35,9 +36,13 @@ do_output (int s, glibtop_response *resp, off_t offset
|
|
resp->offset = offset;
|
|
resp->data_size = data_size;
|
|
|
|
+retry1:
|
|
if (s == 0) {
|
|
- if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0)
|
|
+ if (write (1, (const void *) resp, sizeof (glibtop_response)) < 0) {
|
|
+ if (errno == EINTR)
|
|
+ goto retry1;
|
|
glibtop_warn_io ("write");
|
|
+ }
|
|
} else {
|
|
if (send (s, (const void *) resp, sizeof (glibtop_response), 0) < 0)
|
|
glibtop_warn_io ("send");
|
|
@@ -48,9 +53,13 @@ do_output (int s, glibtop_response *resp, off_t offset
|
|
fprintf (stderr, "Writing %d bytes of data.\n", resp->data_size);
|
|
#endif
|
|
|
|
+retry2:
|
|
if (s == 0) {
|
|
- if (write (1, data, resp->data_size) < 0)
|
|
+ if (write (1, data, resp->data_size) < 0) {
|
|
+ if (errno == EINTR)
|
|
+ goto retry2;
|
|
glibtop_warn_io ("write");
|
|
+ }
|
|
} else {
|
|
if (send (s, data, resp->data_size, 0) , 0)
|
|
glibtop_warn_io ("send");
|
|
@@ -66,6 +75,7 @@ do_read (int s, void *ptr, size_t total_size)
|
|
size_t already_read = 0, remaining = total_size;
|
|
|
|
while (already_read < total_size) {
|
|
+retry:
|
|
if (s)
|
|
nread = recv (s, ptr, remaining, 0);
|
|
else
|
|
@@ -77,6 +87,8 @@ do_read (int s, void *ptr, size_t total_size)
|
|
}
|
|
|
|
if (nread <= 0) {
|
|
+ if (errno == EINTR)
|
|
+ goto retry;
|
|
glibtop_warn_io ("recv");
|
|
return 0;
|
|
}
|