Author: mturk
Date: Tue Sep  6 11:29:40 2011
New Revision: 1165610

URL: http://svn.apache.org/viewvc?rev=1165610&view=rev
Log:
Sync parent and child tests

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/sendfd.c
    
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSendSocket.java

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/sendfd.c
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/sendfd.c?rev=1165610&r1=1165609&r2=1165610&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/sendfd.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/sendfd.c Tue Sep  6 
11:29:40 2011
@@ -68,6 +68,7 @@ HANDLE recv_pipe(LPCWSTR name)
     HANDLE ph;
     DWORD  wr;
     WSAPROTOCOL_INFO id;
+
     ph = CreateFileW(name,
                      GENERIC_READ | GENERIC_WRITE,
                      0,
@@ -77,8 +78,6 @@ HANDLE recv_pipe(LPCWSTR name)
                      0);
     if (ph == INVALID_HANDLE_VALUE)
         return 0;
-    if (!ConnectNamedPipe(ph, 0))
-        rc = GetLastError();
     id.dwProviderReserved = GetCurrentProcessId();
     if (WriteFile(ph, &id, sizeof(WSAPROTOCOL_INFO), &wr, 0))
         return ph;

Modified: 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSendSocket.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSendSocket.java?rev=1165610&r1=1165609&r2=1165610&view=diff
==============================================================================
--- 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSendSocket.java
 (original)
+++ 
commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestSendSocket.java
 Tue Sep  6 11:29:40 2011
@@ -20,34 +20,56 @@ import java.io.IOException;
 import java.io.File;
 import org.testng.annotations.*;
 import org.testng.Assert;
+import org.apache.commons.runtime.Semaphore;
 
 public class TestSendSocket extends Assert
 {
 
+    private static final String semname = "acrSemop23";
+
     @Test(groups = { "sendsd.parent" })
     public void sendSocket()
         throws Exception
     {
+        Semaphore s = Semaphore.create(semname, 0);
+        assertNotNull(s);
         SocketServerEndpoint ss = new SocketServerEndpoint();
         InetSocketAddress    sa = new InetSocketAddress("127.0.0.1", 0);
         ss.bind(sa);        
         long fds[] = new long[1];
         fds[0] = ss.descriptor().fd();
         Utils.sendSockets(Utils.sendSocketName(0), fds, 0, 1);
+        s.acquire();        
         System.out.println("[parent] Done.");
         System.out.flush();
+        s.close();
     }
 
     @Test(groups = { "sendsd.child" })
     public void recvSocket()
         throws Exception
     {
+        
         System.out.println("[child]  Geting sockets");
         System.out.flush();
+        Semaphore s = null;
+        int step = 125;
+        while (step <= 2000) {
+            try {
+                s = Semaphore.open(semname);
+                break;
+            } catch (Exception x) {
+
+            }
+            Thread.sleep(step);
+            step *= 2;
+        }
+        assertNotNull(s);        
         long[] fds = Utils.recvSockets(Utils.sendSocketName(0));
         assertEquals(fds.length, 1);
         System.out.println("[child]  Done.");
         System.out.flush();
+        s.release();
     }
 
 }


Reply via email to