I've had a client ask if it's possible to rename his server log file whilst the server is running but not allow deletion. This is harder than you'd expect to achieve. The established view of "the internet" is that NTFS doesn't support permissions to allow file renaming and still prevent file deletion. This is true. If you want to allow renaming you need to create or open the file with FILE_SHARE_DELETE access and this allows rename AND delete. The reason for this is that a rename is actually a process of creating a copy of the file with a new name and then deleting the old file. I pointed this out to my client and he immediately responded with "I can rename a running exe but am prevented from deleting it.". This, of course, is true. Executable files can be renamed and not deleted if they are currently running.

The fact that executables can work this way gave me the hint I needed. I figured it's likely the fact that the file is mapped into memory that prevents the deletion...

Adding some code that uses CreateFileMapping() to create a file mapping object from the log file's file handle, and then holding the file mapping open whilst we're using the log, gives the results that my client wants. A log file that can be renamed but not deleted. Note that you don't actually have to map the file mapping into memory, just hold the handle open.

Note that the file in question needs to contain at least one byte to be able to create the file mapping but that's easy to work around for us.

As of the latest Chrome, Edge, Opera, and FireFox updates all of my 'obsolete' hardware (routers, NAS drives, network switches, etc) are inaccessible as they don't use TLS 1.2. I'm unlikely to be alone in this. I can understand the technical decision but IMHO it's wrong and, actually pretty stupid. To make it more than a click through warning to access these obsolete devices on my local subnet. Sure ban connections to other subnets (that would cause me pain too as I manage some stuff via a VPN) but 90% of users would be fine.

So now we'll see a lot of "The client and server don't support a common SSL protocol version or cipher suite." or "This site can't provide a secure connection" errors when trying to access older hardware.

I now have an old version of FireFox installed with updates disabled and I know to only use it for my local stuff that doesn't work with updated browsers. It's a bit clunky, even with shortcuts which run the browser with the correct URL, but it works. I'm not sure that everyone will end up with this kind of set up; they may just have someone suggest that they downgrade their main browser and turn off updates...

Allowing access to the local subnet with a click through scary warning would probably be 'safer' than forcing people to find out how to work around the problem or preventing them from ever adjusting their routers, or whatever, again...

I'm sure there are lots and lots of valid reasons for the decision; they're just all wrong when the end result will be non-technical users downgrading their browsers and turning off updates.

More of the same...

2021 was another "interesting" year. We hope that things worked out OK for you. We've stayed nice and busy doing the things we love to do. So lots more C++ on various platforms for various clients.

For us, and a few of our clients, 2021 was the year that NUMA really started to be a thing. Mostly, up until now, we've been able to ignore NUMA hardware. Most clients scale out across cheap hardware and we're used to dealing with that. In 2021 some clients decided to scale the machine rather than the system and started using huge multi-cpu NUMA machines. This was 'interesting' from a performance point of view and we've all learnt a lot whilst tweaking code to make it a better fit for NUMA hardware.

We're still nice and busy with our games clients and our industrial control clients. We're enjoying being able to move towards newer compilers which support more recent versions of C++ and loving all the new learning we're being forced to for performance tuning on various platforms. Long may it continue.

As always, in these interesting times; stay safe and healthy and good luck in 2022!
Back in 2009 I mused on the idea of 'breakpoint sequences', where a breakpoint was only hit if a series of previous breakpoints have been hit.

This functionality now exists in Visual Studio 2022, and it's wonderful. It's useful enough for me to immediately switch from VS2017 to VS2022 as my "day to day" IDE for Windows. Normally I take forever to make the move as I have tools that manage projects and solutions across all the compilers that I support, I just develop in the one that works best for me.

It's like Christmas has come early! Thank you Visual Studio Dev Team!

Recent release notifications

We've just found out that an email misconfiguration means that some emails to serverframework.com email addresses have been bouncing. This should be fixed now! Sorry about the inconvenience. If you have contacted us recently and not had a reply, please try again now!

Recent releases and 8.0 beta

As you'll see, we released 3 new versions of The Server Framework today. Of these, only the 7.3 release includes code changes. The 7.2 release updates almost every header file in the framework to remove 'old style' include guards and touches lots of source files to remove lint directives that we no longer use. This kind of change creates a lot of noise in an update and so it has been done separately to the functional changes to make it easier for users of the framework to see what has actually been changed in 7.3.

Release 7.3 is where the fun happens, with lots of changes and a couple of bug fixes.

Release 7.4 then removes support for Visual Studio 2015 and removes some code that has been deprecated for a while. It's a clean up release.

The idea is, most people should move straight to 7.4. If you want to see exactly what has changed, then ask for 7.2 and 7.3 and compare the 7.3 tree to the 7.2 tree. If you find that you still need Visual Stuido 2015 then stick with 7.3 and get all the new stuff, but no further updates. If you still need some deprecated code, then stick with 7.3.

Almost everything "non-functional" in the 7.x releases has been to pave the way for the forthcoming 8.0 release which supports Linux and MacOS as well as Windows. Lots changes in 8.0 including the entire design of the socket code. This makes it easier to 'plug in' different platforms as back-ends and incorporates lots of stuff that we've learnt over the 20 years since we release the first version of the framework.

We are happy to announce that 8.0 is now in beta. If you'd like to take part in the beta then please get in touch.

Latest release of The Server Framework: 7.4

Version 7.4 of The Server Framework was released today.

This release includes no bug fixes and no new code. It removes deprecated code and removes support for Visual Studio 2015.

Latest release of The Server Framework: 7.3

Version 7.3 of The Server Framework was released today.

This release includes bug fixes and new code.

Latest release of The Server Framework: 7.2

Version 7.2 of The Server Framework was released today.

This release includes no bug fixes and no new code. It adds support for Visual Studio 2022 and removes redundant manual include guards from most header files and removes unused "lint" directives from some of the older files. As such this release just serves as a stepping stone to the 7.3 release and makes it easier to see the changes that are made in the 7.3 release.

Be careful what you ask for...


As I mentioned in May last year, I'd was having trouble with a client's system where a UDP DDOS was causing Windows Server machines to use all available non-paged pool and then blue screen.

The issue could be reproduced with, what I thought at the time was, a minimal test program that simply created a UDP socket, bound it to a port and then didn't do anything with it. If something sent a stream of datagrams to that port then non-paged pool usage would grow in an uncontrolled manner until the box became unusable and eventually died.

The client's DDOS issue was resolved up-stream from them and we promptly forgot about this strange behaviour but recently we've been doing some load testing and we've run into it again so, once I worked out what was going on, I revisited the tests to make sure the minimal code could still be used to reproduce the problem.

Unfortunately the test program wasn't quite minimal enough, as well as creating and binding it also set the socket's recv buffer size to 'max int'. Before the Windows Update that first cause the problem this didn't seem to matter, possibly because the value was being ignored or Windows stopped buffering when non-paged pool usage got too high. After the Windows Update that brought the issue to my attention Windows does just what you ask it and buffers the data and doesn't care that its using all your non-paged pool whilst it's doing that... Or, perhaps, before non-paged pool wasn't used by this buffered data...

Removing the 'set recv buffer size to max' calls seems to fix the problem. Setting the value to something large, but not too large, and then watching the non-paged pool and Microsoft Windows BSP Dropped Datagrams counters perfmon counters clearly shows what's happening. Data is buffered until the buffer space is used and then datagrams are dropped. The buffered data uses non-paged pool in addition to whatever memory is also used for the data.

Deciding on what size buffer you need is complicated by the fact that the socket recv buffer is in bytes and is used up by the payload bytes in the datagrams whereas the non-paged pool usage appears to be "per datagram", so if the sender is sending large datagrams then the recv buffer space is used up sooner and datagrams begin to be dropped with less non-paged pool memory being used. With very small datagrams the non-paged pool usage becomes dangerous far sooner.

Working out a trade-off that allows for normal usage patterns but protects against a DDOS with small amounts of data may be complicated and may require auto-tuning based on the dropped datagrams and non-paged pool perf counters...

About this Blog

I usually write about C++ development on Windows platforms, but I often ramble on about other less technical stuff...

This page contains recent content. Look in the archives to find all content.

I have other blogs...

Subscribe to feed The Server Framework - high performance server development
Subscribe to feed Lock Explorer - deadlock detection and multi-threaded performance tools
Subscribe to feed l'Hexapod - embedded electronics and robotics