Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressed SCP Hanging Issue #376

Merged
merged 1 commit into from
May 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contrib/win32/win32compat/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,12 +916,19 @@ fileio_fdopen(struct w32_io* pio, const char *mode)
{
wchar_t *file_path, *wmode = NULL;
FILE* ret = NULL;
DWORD type = 0;

debug4("fdopen - io:%p", pio);

if ((wmode = utf8_to_utf16(mode)) == NULL)
goto cleanup;

/* for non-disk files, just return the descriptor */
type = GetFileType(pio->handle);
if (type != FILE_TYPE_DISK) {
return _fdopen(pio->table_index, mode);

Choose a reason for hiding this comment

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

relevant info - if the Windows handle associated with "fd" is originally opened as OVERLAPPED (as is the case with all file and pipe handles opened in the posix adapter), all synchronous operations on FILE returned by _fdopen will hang.

It is for that reason, the subsequent logic works around calling _fdopen directly on file handles. Are you not seeing the above behavior for pipe handles?

Copy link
Author

Choose a reason for hiding this comment

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

No, I do not see a hang -- this returns the handle successfully for the named pipe. The only "hang" I see is that one caused by the get_final_path_by_handle() returning NULL for a non-disk file which prevents the parent function from receiving the pipe handle which in turns prevents the calling function from receiving the error and closing the connection.

}

file_path = get_final_path_by_handle(pio->handle);
if (!file_path)
goto cleanup;
Expand Down