You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2022/01/05 16:45:24 UTC

svn commit: r1896719 - in /apr/apr/trunk/file_io/win32: filestat.c flock.c open.c

Author: ivan
Date: Wed Jan  5 16:45:23 2022
New Revision: 1896719

URL: http://svn.apache.org/viewvc?rev=1896719&view=rev
Log:
Remove Windows 95 compatibility code.

Modified:
    apr/apr/trunk/file_io/win32/filestat.c
    apr/apr/trunk/file_io/win32/flock.c
    apr/apr/trunk/file_io/win32/open.c

Modified: apr/apr/trunk/file_io/win32/filestat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filestat.c?rev=1896719&r1=1896718&r2=1896719&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filestat.c (original)
+++ apr/apr/trunk/file_io/win32/filestat.c Wed Jan  5 16:45:23 2022
@@ -675,42 +675,35 @@ APR_DECLARE(apr_status_t) apr_stat(apr_f
              * to reliably translate char devices to the path '\\.\device'
              * so go ask for the full path.
              */
-            if (apr_os_level >= APR_WIN_NT)
+            apr_wchar_t tmpname[APR_FILE_MAX];
+            apr_wchar_t *tmpoff = NULL;
+            if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t),
+                                 tmpname, &tmpoff))
             {
-                apr_wchar_t tmpname[APR_FILE_MAX];
-                apr_wchar_t *tmpoff = NULL;
-                if (GetFullPathNameW(wfname, sizeof(tmpname) / sizeof(apr_wchar_t),
-                                     tmpname, &tmpoff))
-                {
-                    if (!wcsncmp(tmpname, L"\\\\.\\", 4)) {
-                        if (tmpoff == tmpname + 4) {
-                            finfo->filetype = APR_CHR;
-                        }
-                        /* For WHATEVER reason, CHR devices such as \\.\con 
-                         * or \\.\lpt1 *may*not* update tmpoff; in fact the
-                         * resulting tmpoff is set to NULL.  Guard against 
-                         * either case.
-                         *
-                         * This code is identical for wide and narrow chars...
-                         */
-                        else if (!tmpoff) {
-                            tmpoff = tmpname + 4;
-                            while (*tmpoff) {
-                                if (*tmpoff == '\\' || *tmpoff == '/') {
-                                    break;
-                                }
-                                ++tmpoff;
-                            }
-                            if (!*tmpoff) {
-                                finfo->filetype = APR_CHR;
+                if (!wcsncmp(tmpname, L"\\\\.\\", 4)) {
+                    if (tmpoff == tmpname + 4) {
+                        finfo->filetype = APR_CHR;
+                    }
+                    /* For WHATEVER reason, CHR devices such as \\.\con 
+                     * or \\.\lpt1 *may*not* update tmpoff; in fact the
+                     * resulting tmpoff is set to NULL.  Guard against 
+                     * either case.
+                     *
+                     * This code is identical for wide and narrow chars...
+                     */
+                    else if (!tmpoff) {
+                        tmpoff = tmpname + 4;
+                        while (*tmpoff) {
+                            if (*tmpoff == '\\' || *tmpoff == '/') {
+                                break;
                             }
+                            ++tmpoff;
+                        }
+                        if (!*tmpoff) {
+                            finfo->filetype = APR_CHR;
                         }
                     }
                 }
-                else {
-                    finfo->valid &= ~APR_FINFO_TYPE;
-                }
-
             }
             else {
                 finfo->valid &= ~APR_FINFO_TYPE;

Modified: apr/apr/trunk/file_io/win32/flock.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/flock.c?rev=1896719&r1=1896718&r2=1896719&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/flock.c (original)
+++ apr/apr/trunk/file_io/win32/flock.c Wed Jan  5 16:45:23 2022
@@ -24,35 +24,11 @@ APR_DECLARE(apr_status_t) apr_file_lock(
     flags = ((type & APR_FLOCK_NONBLOCK) ? LOCKFILE_FAIL_IMMEDIATELY : 0)
           + (((type & APR_FLOCK_TYPEMASK) == APR_FLOCK_SHARED) 
                                        ? 0 : LOCKFILE_EXCLUSIVE_LOCK);
-    if (apr_os_level >= APR_WIN_NT) {
-        /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
-        OVERLAPPED offset;
-        memset (&offset, 0, sizeof(offset));
-        if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
-            return apr_get_os_error();
-    }
-    else {
-        /* On Win9x, LockFile() never blocks.  Hack in a crufty poll.
-         *
-         * Note that this hack exposes threads to being unserviced forever,
-         * in the situation that the given lock has low availability.
-         * When implemented in the kernel, LockFile will typically use
-         * FIFO or round robin distribution to ensure all threads get 
-         * one crack at the lock; but in this case we can't emulate that.
-         *
-         * However Win9x are barely maintainable anyways, if the user does
-         * choose to build to them, this is the best we can do.
-         */
-        while (!LockFile(thefile->filehand, 0, 0, len, 0)) {
-            DWORD err = GetLastError();
-            if ((err == ERROR_LOCK_VIOLATION) && !(type & APR_FLOCK_NONBLOCK))
-            {
-                Sleep(500); /* pause for a half second */
-                continue;   /* ... and then poll again */
-            }
-            return APR_FROM_OS_ERROR(err);
-        }
-    }
+    /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+    OVERLAPPED offset;
+    memset (&offset, 0, sizeof(offset));
+    if (!LockFileEx(thefile->filehand, flags, 0, len, len, &offset))
+        return apr_get_os_error();
 
     return APR_SUCCESS;
 }
@@ -61,17 +37,11 @@ APR_DECLARE(apr_status_t) apr_file_unloc
 {
     DWORD len = 0xffffffff;
 
-    if (apr_os_level >= APR_WIN_NT) {
-        /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
-        OVERLAPPED offset;
-        memset (&offset, 0, sizeof(offset));
-        if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
-            return apr_get_os_error();
-    }
-    else {
-        if (!UnlockFile(thefile->filehand, 0, 0, len, 0))
-            return apr_get_os_error();
-    }
+    /* Syntax is correct, len is passed for LengthLow and LengthHigh*/
+    OVERLAPPED offset;
+    memset (&offset, 0, sizeof(offset));
+    if (!UnlockFileEx(thefile->filehand, 0, len, len, &offset))
+        return apr_get_os_error();
 
     return APR_SUCCESS;
 }

Modified: apr/apr/trunk/file_io/win32/open.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/open.c?rev=1896719&r1=1896718&r2=1896719&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/open.c (original)
+++ apr/apr/trunk/file_io/win32/open.c Wed Jan  5 16:45:23 2022
@@ -268,7 +268,7 @@ APR_DECLARE(apr_status_t) apr_file_open(
     DWORD oflags = 0;
     DWORD createflags = 0;
     DWORD attributes = 0;
-    DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+    DWORD sharemode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
     apr_status_t rv;
     apr_wchar_t wfname[APR_PATH_MAX];
 
@@ -286,9 +286,6 @@ APR_DECLARE(apr_status_t) apr_file_open(
         oflags |= FILE_WRITE_ATTRIBUTES;
     }
 
-    if (apr_os_level >= APR_WIN_NT) 
-        sharemode |= FILE_SHARE_DELETE;
-
     if (flag & APR_FOPEN_CREATE) {
         if (flag & APR_FOPEN_EXCL) {
             /* only create new if file does not already exist */
@@ -329,9 +326,7 @@ APR_DECLARE(apr_status_t) apr_file_open(
      */
     if (!(flag & (APR_FOPEN_READ | APR_FOPEN_WRITE))) {
         if (flag & APR_OPENINFO) {
-            if (apr_os_level >= APR_WIN_NT) {
-                attributes |= FILE_FLAG_BACKUP_SEMANTICS;
-            }
+            attributes |= FILE_FLAG_BACKUP_SEMANTICS;
         }
         else {
             return APR_EACCES;