[SERVER-6794] Incorrect use of WSAGetLastError() to get file system error code (Windows) Created: 17/Aug/12  Updated: 11/Jul/16  Resolved: 05/Sep/12

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.3.0

Type: Bug Priority: Minor - P4
Reporter: Tad Marshall Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: Windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows


Backwards Compatibility: Fully Compatible
Operating System: Windows
Participants:

 Description   

From code inspection:
src/mongo/db/instance.cpp lines 1008 to 1010:

#ifdef _WIN32
    if( _chsize( lockFile , 0 ) )
        log() << "couldn't remove fs lock " << WSAGetLastError() << endl;

WSAGetLastError() does not return anything useful here – this is for WinSock errors. Here, it will always print "0".
Better code would be:

#ifdef _WIN32
    if( _chsize( lockFile , 0 ) )
        log() << "couldn't remove fs lock " << errnoWithDescription(_doserrno) << endl;

which will print the errno value and the system text, for example:

couldn't remove fs lock errno:6 The handle is invalid.



 Comments   
Comment by auto [ 05/Sep/12 ]

Author:

{u'date': u'2012-09-03T08:28:45-07:00', u'email': u'tad@10gen.com', u'name': u'Tad Marshall'}

Message: SERVER-6794 do not use WSAGetLastError() for file system errors
Branch: master
https://github.com/mongodb/mongo/commit/1e0cb106d3f18645d1eb5b93372f43f37ae8ff76

Generated at Thu Feb 08 03:12:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.