[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28585 - msh/src
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28585 - msh/src |
Date: |
Tue, 13 Aug 2013 22:56:12 +0200 |
Author: harsha
Date: 2013-08-13 22:56:12 +0200 (Tue, 13 Aug 2013)
New Revision: 28585
Added:
msh/src/launch_ll.c
Modified:
msh/src/
msh/src/launch.c
msh/src/mshd-server.c
Log:
- evidence for broken pipe bug
Index: msh/src
===================================================================
--- msh/src 2013-08-13 19:16:52 UTC (rev 28584)
+++ msh/src 2013-08-13 20:56:12 UTC (rev 28585)
Property changes on: msh/src
___________________________________________________________________
Modified: svn:ignore
## -8,3 +8,7 ##
test-scheduler*
test-bitmap*
test-addressmap*
+prop
+launch
+launch-ll
+core
Modified: msh/src/launch.c
===================================================================
--- msh/src/launch.c 2013-08-13 19:16:52 UTC (rev 28584)
+++ msh/src/launch.c 2013-08-13 20:56:12 UTC (rev 28585)
@@ -9,9 +9,9 @@
struct GNUNET_DISK_FileHandle *fin;
struct GNUNET_DISK_FileHandle *fout;
char *cmd[] = {"./prop", NULL};
- char *str = "Hello World";
+ char *str = "Hello World\n";
char buf[256];
- ssize_t read;
+ ssize_t rx;
GNUNET_log_setup ("msh-launch", NULL, NULL);
pin = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, 0, 0);
@@ -26,15 +26,18 @@
fout = GNUNET_DISK_pipe_detach_end (pout, GNUNET_DISK_PIPE_END_READ);
GNUNET_assert (GNUNET_OK == GNUNET_DISK_pipe_close (pin));
GNUNET_assert (GNUNET_OK == GNUNET_DISK_pipe_close (pout));
- /* GNUNET_break (strlen (str) */
- /* == GNUNET_DISK_file_write_blocking (fin, str, strlen
(str))); */
- read = GNUNET_DISK_file_read (fout, buf, sizeof (buf));
- GNUNET_assert (GNUNET_SYSERR != read);
- if (0 == read)
+ GNUNET_break (strlen (str)
+ == GNUNET_DISK_file_write_blocking (fin, str, strlen (str)));
+ errno = 0;
+ rx = GNUNET_DISK_file_read (fout, buf, sizeof (buf));
+ if (0 != errno)
+ perror ("read");
+ GNUNET_assert (GNUNET_SYSERR != rx);
+ if (0 == rx)
{
GNUNET_break (0);
return 1;
}
- fwrite (buf, read, 1, stdout);
+ fwrite (buf, rx, 1, stdout);
return 0;
}
Added: msh/src/launch_ll.c
===================================================================
--- msh/src/launch_ll.c (rev 0)
+++ msh/src/launch_ll.c 2013-08-13 20:56:12 UTC (rev 28585)
@@ -0,0 +1,47 @@
+#define _GNU_SOURCE
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+
+int main ()
+{
+ int inpipe[2];
+ int outpipe[2];
+ pid_t cid;
+ int status;
+ char *str = "Hello World\n";
+ char buf[256];
+ ssize_t rx;
+
+ assert (0 == pipe2 (inpipe, O_CLOEXEC));
+ assert (0 == pipe2 (outpipe, O_CLOEXEC));
+ cid = fork ();
+ assert (-1 != cid);
+ if (0 == cid)
+ {
+ assert (0 == close (0));
+ assert (-1 != (dup2 (inpipe[0], 0)));
+ assert (0 == close (inpipe[1]));
+ assert (0 == close (inpipe[0]));
+
+ assert (0 == close (1));
+ assert (-1 != (dup2 (outpipe[1], 1)));
+ assert (0 == close (outpipe[1]));
+ assert (0 == close (outpipe[0]));
+
+ (void) execlp ("./prop", "prop", (char *) NULL);
+ assert (0);
+ }
+ assert (strlen (str) == write (inpipe[1], str, strlen (str)));
+ rx = read (outpipe[0], buf, sizeof (buf));
+ assert (-1 != rx);
+ if (rx < sizeof (buf))
+ buf[rx] = '\0';
+ printf ("%.256s", buf);
+ assert (cid == wait (&status));
+ return 0;
+}
Modified: msh/src/mshd-server.c
===================================================================
--- msh/src/mshd-server.c 2013-08-13 19:16:52 UTC (rev 28584)
+++ msh/src/mshd-server.c 2013-08-13 20:56:12 UTC (rev 28585)
@@ -195,7 +195,6 @@
{
unsigned int cnt;
- GNUNET_break (0);
if (NULL != ctx->args)
{
for (cnt = 0; NULL != ctx->args[cnt]; cnt++)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28585 - msh/src,
gnunet <=