[cpp-sp] branch main updated: Build/Win32 More idiotic windows issues

Rod Widdowson rdw at steadingsoftware.com
Thu Jun 19 18:55:10 UTC 2025


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=fef5be4d405ea19fa70b8bb9fc5bd22648fd39bd

The following commit(s) were added to refs/heads/main by this push:
     new fef5be4d Build/Win32 More idiotic windows issues
fef5be4d is described below

commit fef5be4d405ea19fa70b8bb9fc5bd22648fd39bd
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Jun 19 19:53:13 2025 +0100

    Build/Win32 More idiotic windows issues
    
    1) For some reason windows is picky about utime
    2) Equally in out build a std::filesystem::path::value_type is a 16 bit character.
---
 shibsp/session/impl/FilesystemSessionCache.cpp | 16 +++++++++++++---
 shibsp/util/Misc.cpp                           | 11 +++++++++++
 shibsp/util/Misc.h                             |  3 +++
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/shibsp/session/impl/FilesystemSessionCache.cpp b/shibsp/session/impl/FilesystemSessionCache.cpp
index 07c8aff3..84f6065f 100644
--- a/shibsp/session/impl/FilesystemSessionCache.cpp
+++ b/shibsp/session/impl/FilesystemSessionCache.cpp
@@ -34,11 +34,12 @@
 # include <filesystem>
 #endif
 
+#include <fcntl.h>
+
 #ifdef WIN32
-# define _utime utime
 # include <sys/utime.h>
+# include <io.h>
 #else
-# include <fcntl.h>
 # include <utime.h>
 # include <signal.h>
 # ifdef HAVE_PTHREAD
@@ -460,15 +461,24 @@ void* FilesystemSessionCache::file_cleanup_fn(void* p)
                 // into a time_t. So we'll have to use our helper via stat to obtain the
                 // timestamp.
 
-                const char* pathname = dir_entry.path().c_str();
+                auto* pathname = dir_entry.path().c_str();
                 time_t modified = FileSupport::getModificationTime(pathname);
                 if (modified > 0 && now - modified > fileTimeout) {
+#ifdef WIN32
+                    if (_wremove(pathname) == 0) {
+                        pcache->m_spilog.info("removed stale session file (%S)", pathname);
+                    }
+                    else {
+                        pcache->m_spilog.info("error removing stale session file (%S), errno=%d", pathname, errno);
+                    }
+#else
                     if (std::remove(pathname) == 0) {
                         pcache->m_spilog.info("removed stale session file (%s)", pathname);
                     }
                     else {
                         pcache->m_spilog.info("error removing stale session file (%s), errno=%d", pathname, errno);
                     }
+#endif
                 }
             } 
         }
diff --git a/shibsp/util/Misc.cpp b/shibsp/util/Misc.cpp
index 46d1c3c1..48df59e1 100644
--- a/shibsp/util/Misc.cpp
+++ b/shibsp/util/Misc.cpp
@@ -81,3 +81,14 @@ time_t FileSupport::getModificationTime(const char* path)
 #endif
     return 0;
 }
+
+#ifdef WIN32
+time_t FileSupport::getModificationTime(const wchar_t* path)
+{
+    struct _stat stat_buf;
+    if (_wstat(path, &stat_buf) == 0) {
+        return stat_buf.st_mtime;
+    }
+    return 0;
+}
+#endif
diff --git a/shibsp/util/Misc.h b/shibsp/util/Misc.h
index 441b42a1..7e8cfba2 100644
--- a/shibsp/util/Misc.h
+++ b/shibsp/util/Misc.h
@@ -99,6 +99,9 @@ namespace shibsp {
          * @return modification time or 0 if unable
          */
         static time_t getModificationTime(const char* path);
+#if WIN32
+        static time_t getModificationTime(const wchar_t* path);
+#endif
     };
 
     /**

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list