Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

os: modify os.tmpdir() to judge more recommended order in windows #5083

Closed
wants to merge 2 commits into from

Conversation

doortts
Copy link

@doortts doortts commented Mar 19, 2013

If someone(e.g. amdin) want to use an old NT command script
or has installed old windows in another dirve,
then %SystemRoot% would be more suitable.
And %windir is also used for old windows compatibility.

See: #3407

If someone(e.g. amdin) want to use an old NT command script
or has installed old windows in another dirve,
then %SystemRoot% would be more suitable.
And %windir is also used for old windows compatibility.

See: nodejs#3407
@doortts
Copy link
Author

doortts commented Mar 19, 2013

Also, usually windows users set their temporary folder with variable TEMP, not TMP.
TMP was used only for old dos command line apps.
So, TEMP must come first.

see:

@isaacs
Copy link

isaacs commented Mar 19, 2013

On Unix systems, TMP should come first. Also, the style needs to be updated to remove the long line.

It would probably be best to just have a different function on Windows entirely.

process.env.TEMP ||
(process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp');
process.env.TMP ||
(process.platform === 'win32' ? (process.env.systemroot || process.env.windir) + "\\temp" : '/tmp');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: Long line.

Implementation: Casing? I thought it was SystemRoot and WinDir.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, windows doesn't care character case of env variables.
And standard expression is SystemRoot and windir

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx

I'll change code style and character cases, and request pull again.
It will be a different function on Windows entirely

Thanks

@bnoordhuis
Copy link
Member

On Unix systems, TMP should come first.

I'm admittedly not 100% sure what the standard is (if there is one) but glibc looks for $TMPDIR first, then falls back to /tmp. It never considers $TMP.

EDIT: As another data point, musl libc is hard-coded to only use /tmp.

@doortts
Copy link
Author

doortts commented Mar 27, 2013

I know it's subtle and I'm afraid bothering, but may I have a opinion about commit b7f6418, @isaacs @bnoordhuis ?

@bnoordhuis
Copy link
Member

The UNIX side of things LGTM. @piscisaureus or @sblom should sign off on the Windows part.

@piscisaureus
Copy link

LGTM too. @doortts, can you sign the CLA?

@doortts
Copy link
Author

doortts commented Mar 28, 2013

@piscisaureus @bnoordhuis Thanks! I have already signed the CLA. "Suwon Chae" is my full name.

if (isWindows) {
return process.env.TEMP ||
process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + "\\temp";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at it again, it seems that if neither %SystemRoot% or %windir% is set, it'll return 'undefined\\temp'.

/cc @piscisaureus

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True that. However when that happens you have a much bigger problem. Node won't even start any more :)

@bnoordhuis
Copy link
Member

Okay, landed in 120e5a2. Thanks!

@bnoordhuis bnoordhuis closed this Mar 28, 2013
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Feb 18, 2016
The role of `this.server` is now split between `this._server` and
`this.server`. Where the first one is used for counting active
connections of `net.Server`, and the latter one is just a public API for
users' consumption.

The reasoning for this is simple, `TLSSocket` instances wrap
`net.Socket` instances, thus both refer to the `net.Server` through the
`this.server` property. However, only one of them should be used for
`net.Server` connection count book-keeping, otherwise double-decrement
will happen on socket destruction.

Fix: nodejs#5083
PR-URL: nodejs/node#5262
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Mar 2, 2016
The role of `this.server` is now split between `this._server` and
`this.server`. Where the first one is used for counting active
connections of `net.Server`, and the latter one is just a public API for
users' consumption.

The reasoning for this is simple, `TLSSocket` instances wrap
`net.Socket` instances, thus both refer to the `net.Server` through the
`this.server` property. However, only one of them should be used for
`net.Server` connection count book-keeping, otherwise double-decrement
will happen on socket destruction.

Fix: nodejs#5083
PR-URL: nodejs/node#5262
Reviewed-By: James M Snell <[email protected]>
richardlau pushed a commit to ibmruntimes/node that referenced this pull request Mar 9, 2016
The role of `this.server` is now split between `this._server` and
`this.server`. Where the first one is used for counting active
connections of `net.Server`, and the latter one is just a public API for
users' consumption.

The reasoning for this is simple, `TLSSocket` instances wrap
`net.Socket` instances, thus both refer to the `net.Server` through the
`this.server` property. However, only one of them should be used for
`net.Server` connection count book-keeping, otherwise double-decrement
will happen on socket destruction.

Fix: nodejs#5083
PR-URL: nodejs/node#5262
Reviewed-By: James M Snell <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants