About

Adrian Cox offers custom software development and consultancy through Humboldt Solutions Ltd.
View Adrian Cox's profile on LinkedIn

Archives

fsync() Across Platforms

When an application writes a file, the data does not become permanent immediately. The write operation first moves the data into the operating system cache in RAM, where it is vulnerable to system crashes and loss of power. The second step is the transfer to the hard disk, which normally has write caching enabled. The disk acknowledges the data straight away, but keeps it in the disk write cache which is still volatile memory. The data is now safe from system crash1, but is not safe from loss of power. On a modern disk, this may be 16MB or more of data in unknown state.

As performance enhancements in ext4 have made committing data to disk a contentious issue, I’ve written a note on how different platforms handle data consistency.

Continue reading fsync() Across Platforms


  1. Ignoring some worst case scenarios.

The Mystery of ProxyPassReverse

The mod_proxy_ajp module for Apache has many advantages over mod_jk for connecting a Tomcat server to an Apache front. For me, the crucial advantage was the ProxyPassReverseCookiePath directive, which allows me to map the session cookies of a Tomcat web application (other than the root application) into the root of a virtual host.

Unfortunately, many tutorials contain misleading advice, and recommend this pattern for the ProxyPassReverse, which will break if the web application issues a redirect:

ProxyPass /jspdir ajp://localhost:8009/jspdir
ProxyPassReverse /jspdir ajp://localhost:8009/jspdir
Continue reading The Mystery of ProxyPassReverse

Wrapping a Native Library with Maven

I recently converted a large project to build with Maven. The project contained both C++ and Java code, and produced a web application, a standalone server application, plus a number of small command line tools. The project used a large number of open-source Java libraries, and Maven tamed these easily. The native C++ library proved harder, and this is the approach I took.

The code snippets below are part of a complete example that builds a tiny Java/C++ application under Linux. This should port easily to other Unix-like platforms, and may provide some help to performing the same task under Windows. The example is available in tar.gz and zip formats.

Continue reading Wrapping a Native Library with Maven

A Working TFTP Server for Multi-Homed Linux Systems

Linux machines with multiple network interfaces are unreliable as TFTP servers. This issue has been outstanding for a long time, without any resolution. The patch attached to the Debian bug fixes the problem for an old release of tftpd-hpa, but does not apply cleanly to recent releases.

Recent releases of dnsmasq contain a TFTP server which does not have this problem. While this doesn’t solve every case, it provides a tidy solution for a machine which provides BOOTP and TFTP services to several subnets.

Continue reading A Working TFTP Server for Multi-Homed Linux Systems

UTC, SQL Server, and Spring

I’ve recently been introducing the Spring Framework into an existing Java application, using it to speed up adding new features, while making the existing JDBC code more maintainable. One tricky area has been time handling: the application uses an older SQL Server version, so cannot take advantage of the implementation of timestamp with time zone in SQL Server 2008. All the time fields are kept in UTC, and the application must be careful that all the times are converted to and from UTC correctly. With pure JDBC this is handled explicitly, but with Spring JDBC access this is implicit.

Continue reading UTC, SQL Server, and Spring