You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2010/01/20 12:25:17 UTC

svn commit: r901138 - in /commons/sandbox/runtime/trunk/src/main/native: os/unix/exec.c support/win32/support.rc support/win32/wsuexec.c

Author: mturk
Date: Wed Jan 20 11:25:16 2010
New Revision: 901138

URL: http://svn.apache.org/viewvc?rev=901138&view=rev
Log:
Cycle trough all pipes polled

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
    commons/sandbox/runtime/trunk/src/main/native/support/win32/support.rc
    commons/sandbox/runtime/trunk/src/main/native/support/win32/wsuexec.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=901138&r1=901137&r2=901138&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Wed Jan 20 11:25:16 2010
@@ -479,7 +479,7 @@
                     kill(pid, SIGTERM);
                     break;
                 }
-                for (i = 0; i < rc; i++) {
+                for (i = 0; i < npipes; i++) {
 #if defined (DEBUG)
                     if (ps[i].revents == 0) {
                         /* XXX: Seems that event for closed
@@ -488,7 +488,7 @@
                         ACR_DEBUG((THROW_FMARK, "Polled %d from %d with zero revents!", i, rc));
                     }
 #endif
-                    if (pipes[PIPE_STDINP_WRS] == ps[i].fd) {
+                    if (pipes[PIPE_STDINP_WRS] == ps[i].fd && ps[i].revents) {
                         wr = 0;
                         if (ps[i].revents & POLLOUT) {
                             wr = r_write(pipes[PIPE_STDINP_WRS], inpp,
@@ -509,7 +509,7 @@
                                 i_close(&pipes[PIPE_STDINP_WRS]);
                         }
                     }
-                    if (pipes[PIPE_STDOUT_RDS] == ps[i].fd) {
+                    if (pipes[PIPE_STDOUT_RDS] == ps[i].fd && ps[i].revents) {
                         rd = 0;
                         if (ps[i].revents & POLLIN) {
                             rd = r_read(pipes[PIPE_STDOUT_RDS],
@@ -531,7 +531,7 @@
                                 i_close(&pipes[PIPE_STDOUT_RDS]);
                         }
                     }
-                    if (pipes[PIPE_STDERR_RDS] == ps[i].fd) {
+                    if (pipes[PIPE_STDERR_RDS] == ps[i].fd && ps[i].revents) {
                         rd = 0;
                         if (ps[i].revents & POLLIN) {
                             rd = r_read(pipes[PIPE_STDERR_RDS],

Modified: commons/sandbox/runtime/trunk/src/main/native/support/win32/support.rc
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/support/win32/support.rc?rev=901138&r1=901137&r2=901138&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/support/win32/support.rc (original)
+++ commons/sandbox/runtime/trunk/src/main/native/support/win32/support.rc Wed Jan 20 11:25:16 2010
@@ -74,11 +74,23 @@
 #define APP_FILEFLAGS STD_FILEFLAGS
 #endif
 
-#define IDI_MAINICON 101
+#define IDI_MAINICON            101
+#define IDS_APPLICATION         150
+#define IDS_APPVERSION          151
+#define IDS_APPFULLNAME         152
+#define IDS_APPCOPYRIGHT        153
 
 IDI_MAINICON         ICON                       "apache.ico"
 CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST  "commonc.manifest"
 
+STRINGTABLE 
+BEGIN
+    IDS_APPLICATION     STR_INTNAME
+    IDS_APPVERSION      "Version " ACR_VERSION_STRING
+    IDS_APPFULLNAME     STR_INTNAME " Version " ACR_VERSION_STRING
+    IDS_APPCOPYRIGHT    STR_COPYRIGHT
+END
+
 1 VERSIONINFO
  FILEVERSION ACR_VERSION_STRING_CSV
  PRODUCTVERSION ACR_VERSION_STRING_CSV

Modified: commons/sandbox/runtime/trunk/src/main/native/support/win32/wsuexec.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/support/win32/wsuexec.c?rev=901138&r1=901137&r2=901138&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/support/win32/wsuexec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/support/win32/wsuexec.c Wed Jan 20 11:25:16 2010
@@ -27,6 +27,10 @@
 #if !defined(UNICODE)
 #define UNICODE
 #endif
+
+/* Use ACR includes for inlines and platform defines.
+ * Our suEXEC however has no dependency on libacr library
+ */
 #include "acr.h"
 #include "acr_private.h"
 #include "acr_arch.h"
@@ -136,6 +140,15 @@
     _vsnprintf(bp, (size_t)(ep - bp), format, ap);
     va_end(ap);
     OutputDebugStringA(buff);
+    {
+        FILE *log;
+        log = fopen("wsuexec.log", "a+");
+        if (log) {
+            fputs(buff, log);
+            fputc('\n', log);
+            fclose(log);
+        }
+    }
 }
 #define DBG_PRINTF(x) _dbg_printf x
 #else
@@ -392,11 +405,74 @@
     }
 }
 
+LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg,
+                             WPARAM wParam, LPARAM lParam)
+{
+    LRESULT rc = TRUE;
+    switch (uMsg) {
+        case WM_CREATE:
+            DBG_PRINTF(("MainWndProc create"));
+            return TRUE;
+        break;
+        case WM_QUIT:
+            DBG_PRINTF(("MainWndProc WM_QUIT"));
+            return TRUE;
+        break;
+        case WM_ENDSESSION:
+            DBG_PRINTF(("MainWndProc WM_ENDSESSION 0x%08x", lParam));
+            rc = TRUE;
+        break;
+        case WM_QUERYENDSESSION:
+            DBG_PRINTF(("MainWndProc WM_QUERYENDSESSION 0x%08x", lParam));
+            rc = TRUE;
+        break;
+        default:
+            DBG_PRINTF(("MainWndProc calling DefWindowProc 0x%04x", uMsg));
+            rc = DefWindowProc(hWnd, uMsg, wParam, lParam);
+            DBG_PRINTF(("DefWindowProc for 0x%04x returned %d", uMsg, rc));
+        break;
+    }
+    return rc;
+}
+
+static wchar_t *szWndClass = L"WsuEXECclass";
+WNDCLASSEXW     stWndClass;
+HWND            hMainWnd = NULL;
+static DWORD InitMainWindow(HINSTANCE hInstance)
+{
+
+    stWndClass.cbSize = sizeof(WNDCLASSEXW);
+
+    stWndClass.style          = 0;
+    stWndClass.lpfnWndProc    = MainWndProc;
+    stWndClass.cbClsExtra     = 0;
+    stWndClass.cbWndExtra     = 0;
+    stWndClass.hInstance      = NULL;
+    stWndClass.hIcon          = NULL;
+    stWndClass.hIconSm        = NULL;
+    stWndClass.hCursor        = NULL;
+    stWndClass.hbrBackground  = GetStockObject(WHITE_BRUSH);
+    stWndClass.lpszMenuName   = NULL;
+    stWndClass.lpszClassName  = szWndClass;
+
+    if (!RegisterClassExW(&stWndClass))
+        return GetLastError();
+    hMainWnd = CreateWindow(szWndClass, L"wsuEXEC",
+                            0, 0, 0, 0, 0, NULL, NULL,
+                            hInstance, NULL);
+
+    if (!hMainWnd)
+        return GetLastError();
+    else
+        return 0;
+}
+
 int WINAPI wWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPWSTR lpCmdLine,
                     int nCmdShow)
 {
+    MSG msg;
 
     DWORD  rc = 0;
     int    i;
@@ -405,6 +481,16 @@
     wchar_t **argv = NULL;
     wchar_t  *cmdline = NULL;
 
+    /* We don't need the user interaction.
+     * Any attempt to do so would cause the parent to block.
+     * Setting it here will cause this error mode to get inherited
+     * from all child processes.
+     */
+    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+    if ((rc = InitMainWindow(hInstance))) {
+        DBG_PRINTF(("Windows init failed with %d", rc));
+        goto cleanup;
+    }
     args = CommandLineToArrayW(GetCommandLineW(), &argc);
     if (args == NULL) {
         rc = GetLastError();
@@ -425,15 +511,26 @@
         rc = ERROR_NOT_ENOUGH_MEMORY;
         goto cleanup;
     }
+
     DBG_PRINTF(("CCMDLINE='%S'\n", cmdline));
     for (i = 0; i < argc; i++) {
         DBG_PRINTF(("ARGV[%d]='%S'\n", i, argv[i]));
     }
+    for (i = 0; i < __argc; i++) {
+        DBG_PRINTF(("CRTA[%d]='%S'\n", i, __wargv[i]));
+    }
     /* Just for checking the CommandLineToArgvW parser
      * and our wcsquote
      */
     dumpcmdline(cmdline);
 
+    DBG_PRINTF(("Waiting for a message ..."));
+    while (GetMessage(&msg, NULL, 0, 0))  {
+            DBG_PRINTF(("Message %d", msg.message));
+         TranslateMessage(&msg);
+         DispatchMessage(&msg);
+    }
+    DBG_PRINTF(("No more messages"));
     FreeArrayAndElements(args);
     return 0x20000000;