From: Andrew P. <at...@pi...> - 2014-09-26 00:51:28
|
mkstemp() does not exist on Windows, and Naviserver uses it in three places: $ find . -name "*.[ch]" -print | xargs grep -in mkstemp ./nsd/adpeval.c:1183: fd = mkstemp(debugfile); ./nsd/tclhttp.c:426: fd = mkstemp(httpPtr->spoolFileName); ./nsd/driver.c:2301: sockPtr->tfd = mkstemp(sockPtr->tfile); We could stick in our own mkstemp() implementation. Some starting points for that may be: http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32 http://sourceforge.net/p/mingw/bugs/2003/ But Tcl 8.4 and later already have TclpCreateTempFile() (two separate implementations for Unix and Windows), which seems to solve the same problem. It returns a TclFile object, not a file descriptor. Can/should Naviserver's existing users of mkstemp() be modified to instead work with TclpCreateTempFile()? Or will that not quite work, and we should borrow some of the Windows version of TclpCreateTempFile() for direct use in Naviserver? -- Andrew Piskorski <at...@pi...> |
From: Andrew P. <at...@pi...> - 2014-09-26 02:55:45
|
I got the core server to build on Windows. My changes to make that work are here: https://bitbucket.org/apiskors/naviserver https://bitbucket.org/naviserver/naviserver/pull-request/2/changes-to-build-on-windows My changes could definitely use review; my portability tweaks to the C code, etc. Note that I haven't actually solved the mkstemp() problem at all, I just stubbed in a fake function so the code would build. To build on Window with the Microsoft compiler, all you should need to do is make a trivial edit to "naviserver/include/Makefile.build". At the end of that file, comment out the "Makefile.module" line and use the "Makefile.win32" line instead. Then to build, at a Windows command prompt I do: set MY_MSDK="C:\Program Files\Microsoft SDKs\Windows\v7.1" "%MY_MSDK%\Bin\SetEnv.Cmd" /Debug /x64 /win7 z: & cd Z:\ns-fork\naviserver nmake -f Makefile.win32 NAVISERVER=C:\nsd-test -- Andrew Piskorski <at...@pi...> |
From: Andrew P. <at...@pi...> - 2014-09-26 02:59:21
|
Uh oh, Gustaf, I just merged your recent changes into my fork, and now when I try to compile anything, it immediately fails with: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\sdkddkver.h(246) : fatal error C1012: unmatched parenthesis : missing ')' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.EXE"' : return code '0x2' Stop. Likely some Naviserver header file is broken? But only on Windows, it compiles fine on Linux. Any ideas which change it might have been? It seems to be something within these two commits: changeset: 2635:f3d007d12140 date: Tue Jun 18 09:04:55 2013 +0200 changeset: 2866:67bab25f9837 date: Thu Sep 25 11:31:02 2014 +0200 I've no idea what though. I tried "hg bisect" but it refused to do anything; it seems to be confused by the way the Bitbucket fork and merge was done. -- Andrew Piskorski <at...@pi...> |
From: Gustaf N. <ne...@wu...> - 2014-09-26 11:35:22
|
The change [1] should fix the windows behavior (after inspecting an obviously different version of sdkddkver.h, but i can't spot anything else looking suspicious). Does anyone know, why we have a define for _WIN32_WINNT in our sources? Windows should know, what version it has. Maybe a leftover? Andrew, can you check, what happens, if we remove it? -g [1] https://bitbucket.org/naviserver/naviserver/commits/b743a8847dd01704ffdcfe98cc8a95a80ad7eea1 [2] http://sourceforge.net/p/mingw/mingw-org-wsl/ci/9313d16b81162e4d6f58aa5b4a08d16dbcbccdb6/tree/include/sdkddkver.h On 26.09.14 04:59, Andrew Piskorski wrote: > Uh oh, Gustaf, I just merged your recent changes into my fork, and now > when I try to compile anything, it immediately fails with: > > C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\sdkddkver.h(246) : fatal error C1012: unmatched parenthesis : missing ')' > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\cl.EXE"' : return code '0x2' > Stop. |
From: Andrew P. <at...@pi...> - 2014-09-27 14:30:17
|
On Fri, Sep 26, 2014 at 01:15:45PM +0200, Gustaf Neumann wrote: > The change [1] should fix the windows behavior > [1] > https://bitbucket.org/naviserver/naviserver/commits/b743a8847dd01704ffdcfe98cc8a95a80ad7eea1 You're right, that one line change fixed it, thanks! Now with that blocking bug out of the way, it looks I sill have more Windows build failures with your recent changes. I'll do more debugging and see why. > Does anyone know, why we have a define for _WIN32_WINNT in > our sources? > Windows should know, what version it has. Maybe a leftover? > Andrew, can you check, what happens, if we remove it? I tried removing the _WIN32_WINNT definition entirely just now, which DID change the build behavior! It switched to a different set of errors and warnings. So maybe we do need it, but I don't know why. I'll look more once I get the build working again. -- Andrew Piskorski <at...@pi...> |
From: Gustaf N. <ne...@wu...> - 2014-09-26 12:13:10
|
Dear Andrew, We have to be careful on licence mixes. The tcl8.5 version of TclpCreateTempFile uses already mkstemp, but the windows implemetation looks like a slim approach for a win32 implementation (aside of the TclFile handling) using CreateFile* and the appropriate flags to make the file a temp file... -g On 26.09.14 02:51, Andrew Piskorski wrote: > mkstemp() does not exist on Windows, and Naviserver uses it in three > places: > > $ find . -name "*.[ch]" -print | xargs grep -in mkstemp > ./nsd/adpeval.c:1183: fd = mkstemp(debugfile); > ./nsd/tclhttp.c:426: fd = mkstemp(httpPtr->spoolFileName); > ./nsd/driver.c:2301: sockPtr->tfd = mkstemp(sockPtr->tfile); > > We could stick in our own mkstemp() implementation. Some starting > points for that may be: > > http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32 > http://sourceforge.net/p/mingw/bugs/2003/ > > But Tcl 8.4 and later already have TclpCreateTempFile() (two separate > implementations for Unix and Windows), which seems to solve the same > problem. It returns a TclFile object, not a file descriptor. > > Can/should Naviserver's existing users of mkstemp() be modified to > instead work with TclpCreateTempFile()? Or will that not quite work, > and we should borrow some of the Windows version of TclpCreateTempFile() > for direct use in Naviserver? > |
From: Maurizio M. <Mau...@sp...> - 2014-09-26 17:44:57
|
http://msdn.microsoft.com/en-us/library/ms235413.aspx Maurizio -----Original Message----- From: Gustaf Neumann [mailto:ne...@wu...] Sent: 26 September 2014 14:13 To: nav...@li... Subject: Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()? Dear Andrew, We have to be careful on licence mixes. The tcl8.5 version of TclpCreateTempFile uses already mkstemp, but the windows implemetation looks like a slim approach for a win32 implementation (aside of the TclFile handling) using CreateFile* and the appropriate flags to make the file a temp file... -g On 26.09.14 02:51, Andrew Piskorski wrote: > mkstemp() does not exist on Windows, and Naviserver uses it in three > places: > > $ find . -name "*.[ch]" -print | xargs grep -in mkstemp > ./nsd/adpeval.c:1183: fd = mkstemp(debugfile); > ./nsd/tclhttp.c:426: fd = mkstemp(httpPtr->spoolFileName); > ./nsd/driver.c:2301: sockPtr->tfd = mkstemp(sockPtr->tfile); > > We could stick in our own mkstemp() implementation. Some starting > points for that may be: > > http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32 > http://sourceforge.net/p/mingw/bugs/2003/ > > But Tcl 8.4 and later already have TclpCreateTempFile() (two separate > implementations for Unix and Windows), which seems to solve the same > problem. It returns a TclFile object, not a file descriptor. > > Can/should Naviserver's existing users of mkstemp() be modified to > instead work with TclpCreateTempFile()? Or will that not quite work, > and we should borrow some of the Windows version of > TclpCreateTempFile() for direct use in Naviserver? > ---------------------------------------------------------------------------- -- Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ naviserver-devel mailing list nav...@li... https://lists.sourceforge.net/lists/listinfo/naviserver-devel |
From: Maurizio M. <Mau...@sp...> - 2014-09-26 18:55:23
|
Dear Andrew and Gustaf, I believe this is the function you are looking for: http://msdn.microsoft.com/en-us/library/ms235413.aspx Hope it helps, Maurizio -----Original Message----- From: Gustaf Neumann [mailto:ne...@wu...] Sent: 26 September 2014 14:13 To: nav...@li... Subject: Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()? Dear Andrew, We have to be careful on licence mixes. The tcl8.5 version of TclpCreateTempFile uses already mkstemp, but the windows implemetation looks like a slim approach for a win32 implementation (aside of the TclFile handling) using CreateFile* and the appropriate flags to make the file a temp file... -g On 26.09.14 02:51, Andrew Piskorski wrote: > mkstemp() does not exist on Windows, and Naviserver uses it in three > places: > > $ find . -name "*.[ch]" -print | xargs grep -in mkstemp > ./nsd/adpeval.c:1183: fd = mkstemp(debugfile); > ./nsd/tclhttp.c:426: fd = mkstemp(httpPtr->spoolFileName); > ./nsd/driver.c:2301: sockPtr->tfd = mkstemp(sockPtr->tfile); > > We could stick in our own mkstemp() implementation. Some starting > points for that may be: > > http://stackoverflow.com/questions/6036227/mkstemp-implementation-for-win32 > http://sourceforge.net/p/mingw/bugs/2003/ > > But Tcl 8.4 and later already have TclpCreateTempFile() (two separate > implementations for Unix and Windows), which seems to solve the same > problem. It returns a TclFile object, not a file descriptor. > > Can/should Naviserver's existing users of mkstemp() be modified to > instead work with TclpCreateTempFile()? Or will that not quite work, > and we should borrow some of the Windows version of > TclpCreateTempFile() for direct use in Naviserver? > ---------------------------------------------------------------------------- -- Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ naviserver-devel mailing list nav...@li... https://lists.sourceforge.net/lists/listinfo/naviserver-devel |
From: Andrew P. <at...@pi...> - 2014-09-27 14:11:50
|
On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote: > Dear Andrew and Gustaf, > I believe this is the function you are looking for: > > http://msdn.microsoft.com/en-us/library/ms235413.aspx No, it is not. mktemp and friends merely generate a file name, while mkstemp also opens the file and returns a file handle. So yes, you could use mktemp as part of an implementation of mkstemp, but they do are not replacements for each other. -- Andrew Piskorski <at...@pi...> |
From: Gustaf N. <ne...@wu...> - 2014-09-28 14:56:04
|
mktemp() is useful, but is in in the unix world general strongly discouraged in favor of mkstemp(). The problem with mktemp() + file-create is, that in the time between the pathname is constructed and the file is created, another process might have created a file with the same name. mkstemp() is actually guaranteed to create a unique file. For the time being, i've commited a small implementation of mkstemp() for windows, that opens files with O_EXCL, which should be a first approximation. However, it's not tested, please test it and don't be surprised, if it needs more tweaks (maybe my flag settings are too restrictive). all the best -g Am 27.09.14 16:11, schrieb Andrew Piskorski: > On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote: >> Dear Andrew and Gustaf, >> I believe this is the function you are looking for: >> >> http://msdn.microsoft.com/en-us/library/ms235413.aspx > No, it is not. mktemp and friends merely generate a file name, while > mkstemp also opens the file and returns a file handle. So yes, you > could use mktemp as part of an implementation of mkstemp, but they do > are not replacements for each other. > |
From: Maurizio M. <Mau...@sp...> - 2014-09-28 16:04:07
|
Perfect, You eventually landed on using _mktemp_s which is what described in the first link I provided you with and is what I was hoping for Windows. Thanks a lot, Maurizio From: Gustaf Neumann [mailto:ne...@wu...] Sent: 28 September 2014 16:56 To: nav...@li... Subject: Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()? mktemp() is useful, but is in in the unix world general strongly discouraged in favor of mkstemp(). The problem with mktemp() + file-create is, that in the time between the pathname is constructed and the file is created, another process might have created a file with the same name. mkstemp() is actually guaranteed to create a unique file. For the time being, i've commited a small implementation of mkstemp() for windows, that opens files with O_EXCL, which should be a first approximation. However, it's not tested, please test it and don't be surprised, if it needs more tweaks (maybe my flag settings are too restrictive). all the best -g Am 27.09.14 16:11, schrieb Andrew Piskorski: On Fri, Sep 26, 2014 at 08:55:37PM +0200, Maurizio Martignano wrote: Dear Andrew and Gustaf, I believe this is the function you are looking for: http://msdn.microsoft.com/en-us/library/ms235413.aspx No, it is not. mktemp and friends merely generate a file name, while mkstemp also opens the file and returns a file handle. So yes, you could use mktemp as part of an implementation of mkstemp, but they do are not replacements for each other. |
From: Andrew P. <at...@pi...> - 2014-09-27 14:14:44
|
On Fri, Sep 26, 2014 at 02:12:59PM +0200, Gustaf Neumann wrote: > We have to be careful on licence mixes. The tcl8.5 version of > TclpCreateTempFile uses already mkstemp, but the windows I did not consider that at all. But, hm, Tcl uses a quite permissive BSD-like license, so it probably does not matter? If we copy some bits of their code, we may still put it our modified version under Naviserver's Mozilla license? > implemetation looks like a slim approach for a win32 > implementation (aside of the TclFile handling) using > CreateFile* and the appropriate flags to make the file > a temp file... Is that a good fit for Naviserver's needs? -- Andrew Piskorski <at...@pi...> |
From: Andrew P. <at...@pi...> - 2014-09-27 14:09:07
|
On Fri, Sep 26, 2014 at 06:08:39PM +0200, Maurizio Martignano wrote: > http://msdn.microsoft.com/en-us/library/ms235413.aspx No, that is about mktemp (and thus also _mktemp and _mktemp_s), which has quite different behavior from mkstemp. They are not replacements for each other. -- Andrew Piskorski <at...@pi...> |
From: Maurizio M. <Mau...@sp...> - 2014-09-27 15:11:09
|
Well... >From the Posix documentation: "The mkstemp function generates a unique file name just as mktemp does, but it also opens the file for you..." So you can anyhow use the Microsoft version of mktemp to get the file name and then you just open it as you need. I believe this approach is much simpler that creating your own function. As simple as that, Maurizio -----Original Message----- From: Andrew Piskorski [mailto:at...@pi...] Sent: 27 September 2014 16:09 To: nav...@li... Subject: Re: [naviserver-devel] no mkstemp() on Windows, use TclpCreateTempFile()? On Fri, Sep 26, 2014 at 06:08:39PM +0200, Maurizio Martignano wrote: > http://msdn.microsoft.com/en-us/library/ms235413.aspx No, that is about mktemp (and thus also _mktemp and _mktemp_s), which has quite different behavior from mkstemp. They are not replacements for each other. -- Andrew Piskorski <at...@pi...> ---------------------------------------------------------------------------- -- Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ naviserver-devel mailing list nav...@li... https://lists.sourceforge.net/lists/listinfo/naviserver-devel |