Dear Andrew and all,

Over the weekend, I invested some more time into the windows
port and got a better understanding of the logging  issue (a write()
operation succeeds inside nslog.c, but the identically operations
inside driver.c does not work; "not work" means, that the write
operation succeeds (i.e. reports the written number of bytes),
but the file is always empty, even after a close()).

The problem is not a argument-passing or memory problem,
but seems to be a linking problem. When a file is opened in a
module (here nslog) only this module can write successfully
to this file. Under Windows other dlls can't write to it, even
when they write to the same fd. It seems to me as if the
nslog dll is linked to a private runtime environment.
Looking up the windows handle same file descriptor
(e.g. 3) leads to a different results when performed in nslog.c
or in driver.c (or somewhere else in a function in libnsd).

The current solution is to define for windows stub-functions
ns_open, ns_close, ns_write, ns_read which are defined in libnsd.
These functions are called from ns_log instead of the native
OS functions (under windows _open, _close, _write, _read),
which have btw different prototypes, so this abstraction
seems beneficial for several reasons.

The essential change is in [1], which add the ns_* functions and
reverts the previous  _MSV_VER bypass in nslog.c. For
completeness, ns_tell should be added as well.

Andrew, can you compare the linking options for nslog with these
from Maurizio? Although the problem for nslog seems to be solved,
i would not be surprised if other weirdnesses lurch around
from other modules.

-g

[1] 
https://bitbucket.org/naviserver/naviserver/commits/70437a26eef9f5f8c801bd813434b50f761e0d4e


Am 07.11.14 14:00, schrieb Andrew Piskorski:
> On Thu, Nov 06, 2014 at 03:03:18PM +0100, Gustaf Neumann wrote:
>> The seemingly same write() operation, which refuses to write to
>> the access.log in driver.c works fine when called directly
>> in nslog.c.
>>
> Wow, weird.  I tried turning your new fix on/off, and confirm the
> behavior you see.



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to