[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: mm_last_pg+1 != filesize

Hallvard Breien Furuseth wrote:
On 21/12/15 03:39, openldap-commit2devel@OpenLDAP.org wrote:
commit 209b56fead1afe8273db6c714c0a74a9c09b9cf6
Author: Howard Chu <hyc@openldap.org>
Date:   Mon Dec 21 02:36:20 2015 +0000

     ITS#8324 fix for WRITEMAP

     We called FlushViewOfFile with (map,mapsize) which worked fine
     when we had allocated the entire map already. Now we have to make
     sure to only flush as much as was actually written. Add a numpgs
     argument to tell how much to flush in env_sync0().

Do env_sync() and commit() survive the test program from ITS#7886?
It creates a datafile which ends before mm_last_pg+1.

That would probably crash on Windows, I'll check it later. Annoying that Windows doesn't just flush whatever exists and move on.

Could add a filesize check to env_open and fail if last_pgno doesn't match. I'm not too fussed about it, you have to be deliberately malicious to create this condition. You get a Bus Error or a SEGV - that's a lot safer than tamely returning an error code that the caller could ignore.

  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/