winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2017
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
632 discussions
Start a n
N
ew thread
Józef Kucia : wined3d: Translate bfi, ubfe, ibfe instructions more carefully.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: ffb72392b4cedfd0ca6d7cb8aae644d32beeb6c2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ffb72392b4cedfd0ca6d7cb8a…
Author: Józef Kucia <jkucia(a)codeweavers.com> Date: Tue Jul 18 00:17:17 2017 +0200 wined3d: Translate bfi, ubfe, ibfe instructions more carefully. Makes sure that we do not overwrite source parameters for consecutive GLSL function calls when the instruction is translated into multiple lines. Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/glsl_shader.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 650f8ad..ac4dfda 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -4122,6 +4122,8 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) struct wined3d_shader_dst_param dst; struct glsl_src_param src[4]; const char *instruction; + BOOL tmp_dst = FALSE; + char mask_char[6]; unsigned int i, j; DWORD write_mask; @@ -4135,12 +4137,21 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) return; } + for (i = 0; i < ins->src_count; ++i) + { + if (ins->dst[0].reg.idx[0].offset == ins->src[i].reg.idx[0].offset + && ins->dst[0].reg.type == ins->src[i].reg.type) + tmp_dst = TRUE; + } + dst = ins->dst[0]; for (i = 0; i < 4; ++i) { dst.write_mask = ins->dst[0].write_mask & (WINED3DSP_WRITEMASK_0 << i); - if (!(write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins, - &dst, dst.reg.data_type))) + if (tmp_dst && (write_mask = shader_glsl_get_write_mask(&dst, mask_char))) + shader_addline(buffer, "tmp0%s = %sBitsToFloat(", mask_char, + dst.reg.data_type == WINED3D_DATA_INT ? "int" : "uint"); + else if (!(write_mask = shader_glsl_append_dst_ext(buffer, ins, &dst, dst.reg.data_type))) continue; for (j = 0; j < ins->src_count; ++j) @@ -4150,6 +4161,13 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "%s, ", src[ins->src_count - j - 1].param_str); shader_addline(buffer, "%s & 0x1f, %s & 0x1f));\n", src[1].param_str, src[0].param_str); } + + if (tmp_dst) + { + shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_DATA_FLOAT); + shader_glsl_get_write_mask(&ins->dst[0], mask_char); + shader_addline(buffer, "tmp0%s);\n", mask_char); + } } static void shader_glsl_nop(const struct wined3d_shader_instruction *ins) {} @@ -4400,7 +4418,7 @@ static void shader_glsl_swapc(const struct wined3d_shader_instruction *ins) { shader_glsl_get_write_mask(&ins->dst[i], mask_char); shader_glsl_append_dst_ext(buffer, ins, &ins->dst[i], ins->dst[i].reg.data_type); - shader_addline(ins->ctx->buffer, "tmp%u%s);\n", i, mask_char); + shader_addline(buffer, "tmp%u%s);\n", i, mask_char); } } }
1
0
0
0
Alexandre Julliard : ntdll: Don' t copy cached debug registers from the parent thread.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: fed30058bb97c32719557c4ab736cd3ce77273eb URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fed30058bb97c32719557c4ab…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jul 18 11:34:22 2017 +0200 ntdll: Don't copy cached debug registers from the parent thread. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_i386.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 570189a..a40197a 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -2379,7 +2379,6 @@ NTSTATUS signal_alloc_thread( TEB **teb ) { static size_t sigstack_zero_bits; struct ntdll_thread_data *thread_data; - struct ntdll_thread_data *parent_data = NULL; SIZE_T size; void *addr = NULL; NTSTATUS status; @@ -2393,7 +2392,6 @@ NTSTATUS signal_alloc_thread( TEB **teb ) signal_stack_mask = (1 << sigstack_zero_bits) - 1; signal_stack_size = (1 << sigstack_zero_bits) - teb_size; } - else parent_data = ntdll_get_thread_data(); size = signal_stack_mask + 1; if (!(status = NtAllocateVirtualMemory( NtCurrentProcess(), &addr, sigstack_zero_bits, @@ -2409,17 +2407,6 @@ NTSTATUS signal_alloc_thread( TEB **teb ) NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE ); status = STATUS_TOO_MANY_THREADS; } - if (parent_data) - { - /* inherit debug registers from parent thread */ - thread_data->dr0 = parent_data->dr0; - thread_data->dr1 = parent_data->dr1; - thread_data->dr2 = parent_data->dr2; - thread_data->dr3 = parent_data->dr3; - thread_data->dr6 = parent_data->dr6; - thread_data->dr7 = parent_data->dr7; - } - } return status; }
1
0
0
0
Alexandre Julliard : ntdll: Move NtGetContextThread implementation to the platform-specific files.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: ce46de5a942ce972decea8cf0fcfe2fefbb96c1c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ce46de5a942ce972decea8cf0…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jul 18 11:15:46 2017 +0200 ntdll: Move NtGetContextThread implementation to the platform-specific files. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/ntdll_misc.h | 2 +- dlls/ntdll/signal_arm.c | 29 ++++++++++++++++++++++++- dlls/ntdll/signal_arm64.c | 29 ++++++++++++++++++++++++- dlls/ntdll/signal_i386.c | 45 ++++++++++++++++++++++++++++++++++++++- dlls/ntdll/signal_powerpc.c | 29 ++++++++++++++++++++++++- dlls/ntdll/signal_x86_64.c | 32 +++++++++++++++++++++++++++- dlls/ntdll/thread.c | 52 +-------------------------------------------- 7 files changed, 161 insertions(+), 57 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=ce46de5a942ce972decea…
1
0
0
0
Alexandre Julliard : ntdll: Move NtSetContextThread implementation to the platform-specific files.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: 675e8218f0cdc3dbc30e2829d481d6591aebf67c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=675e8218f0cdc3dbc30e2829d…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jul 18 11:08:37 2017 +0200 ntdll: Move NtSetContextThread implementation to the platform-specific files. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/ntdll_misc.h | 2 +- dlls/ntdll/signal_arm.c | 16 ++++++++++++++++ dlls/ntdll/signal_arm64.c | 17 ++++++++++++++++- dlls/ntdll/signal_i386.c | 27 ++++++++++++++++++++++++++- dlls/ntdll/signal_powerpc.c | 17 ++++++++++++++++- dlls/ntdll/signal_x86_64.c | 19 +++++++++++++++++-- dlls/ntdll/thread.c | 38 +------------------------------------- 7 files changed, 93 insertions(+), 43 deletions(-) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 5e4c39e..ee82cea 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -53,10 +53,10 @@ extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN; extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, int first_chance, CONTEXT *context ) DECLSPEC_HIDDEN; extern LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN; extern void raise_status( NTSTATUS status, EXCEPTION_RECORD *rec ) DECLSPEC_NORETURN DECLSPEC_HIDDEN; -extern void set_cpu_context( const CONTEXT *context ) DECLSPEC_HIDDEN; extern void copy_context( CONTEXT *to, const CONTEXT *from, DWORD flags ) DECLSPEC_HIDDEN; extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC_HIDDEN; extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) DECLSPEC_HIDDEN; +extern NTSTATUS set_thread_context( HANDLE handle, const CONTEXT *context, BOOL *self ) DECLSPEC_HIDDEN; extern void call_thread_entry_point( LPTHREAD_START_ROUTINE entry, void *arg ) DECLSPEC_NORETURN DECLSPEC_HIDDEN; /* debug helpers */ diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index cb5f67d..7210c8e 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -294,6 +294,7 @@ __ASM_STDCALL_FUNC( RtlCaptureContext, 4, * Set the new CPU context. */ /* FIXME: What about the CPSR? */ +void set_cpu_context( const CONTEXT *context ); __ASM_GLOBAL_FUNC( set_cpu_context, "mov IP, r0\n\t" "ldr r0, [IP, #0x4]\n\t" /* context->R0 */ @@ -427,6 +428,21 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) return STATUS_SUCCESS; } +/*********************************************************************** + * NtSetContextThread (NTDLL.@) + * ZwSetContextThread (NTDLL.@) + */ +NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) +{ + NTSTATUS ret; + BOOL self; + + ret = set_thread_context( handle, context, &self ); + if (self && ret == STATUS_SUCCESS) set_cpu_context( context ); + return ret; +} + + extern void raise_func_trampoline_thumb( EXCEPTION_RECORD *rec, CONTEXT *context, raise_func func ); __ASM_GLOBAL_FUNC( raise_func_trampoline_thumb, ".thumb\n\t" diff --git a/dlls/ntdll/signal_arm64.c b/dlls/ntdll/signal_arm64.c index ca169a1..77fc8dc 100644 --- a/dlls/ntdll/signal_arm64.c +++ b/dlls/ntdll/signal_arm64.c @@ -231,7 +231,7 @@ __ASM_STDCALL_FUNC( RtlCaptureContext, 8, * * Set the new CPU context. */ -void set_cpu_context( const CONTEXT *context ) +static void set_cpu_context( const CONTEXT *context ) { FIXME( "Not implemented on ARM64\n" ); } @@ -331,6 +331,21 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) } /*********************************************************************** + * NtSetContextThread (NTDLL.@) + * ZwSetContextThread (NTDLL.@) + */ +NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) +{ + NTSTATUS ret; + BOOL self; + + ret = set_thread_context( handle, context, &self ); + if (self && ret == STATUS_SUCCESS) set_cpu_context( context ); + return ret; +} + + +/*********************************************************************** * setup_exception_record * * Setup the exception record and context on the thread stack. diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index d9a0dec..ffb1318 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1230,7 +1230,7 @@ __ASM_STDCALL_FUNC( RtlCaptureContext, 4, * * Set the new CPU context. Used by NtSetContextThread. */ -void set_cpu_context( const CONTEXT *context ) +static void set_cpu_context( const CONTEXT *context ) { DWORD flags = context->ContextFlags & ~CONTEXT_i386; @@ -1461,6 +1461,31 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) /*********************************************************************** + * NtSetContextThread (NTDLL.@) + * ZwSetContextThread (NTDLL.@) + */ +NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) +{ + NTSTATUS ret = STATUS_SUCCESS; + BOOL self = (handle == GetCurrentThread()); + + /* debug registers require a server call */ + if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386))) + self = (ntdll_get_thread_data()->dr0 == context->Dr0 && + ntdll_get_thread_data()->dr1 == context->Dr1 && + ntdll_get_thread_data()->dr2 == context->Dr2 && + ntdll_get_thread_data()->dr3 == context->Dr3 && + ntdll_get_thread_data()->dr6 == context->Dr6 && + ntdll_get_thread_data()->dr7 == context->Dr7); + + if (!self) ret = set_thread_context( handle, context, &self ); + + if (self && ret == STATUS_SUCCESS) set_cpu_context( context ); + return ret; +} + + +/*********************************************************************** * is_privileged_instr * * Check if the fault location is a privileged instruction. diff --git a/dlls/ntdll/signal_powerpc.c b/dlls/ntdll/signal_powerpc.c index 507490a..e44f0b4 100644 --- a/dlls/ntdll/signal_powerpc.c +++ b/dlls/ntdll/signal_powerpc.c @@ -267,7 +267,7 @@ void WINAPI RtlCaptureContext( CONTEXT *context ) * * Set the new CPU context. */ -void set_cpu_context( const CONTEXT *context ) +static void set_cpu_context( const CONTEXT *context ) { FIXME("not implemented\n"); } @@ -568,6 +568,21 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) } +/*********************************************************************** + * NtSetContextThread (NTDLL.@) + * ZwSetContextThread (NTDLL.@) + */ +NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) +{ + NTSTATUS ret; + BOOL self; + + ret = set_thread_context( handle, context, &self ); + if (self && ret == STATUS_SUCCESS) set_cpu_context( context ); + return ret; +} + + /********************************************************************** * call_stack_handlers * diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c index 86034c0..61d95eb 100644 --- a/dlls/ntdll/signal_x86_64.c +++ b/dlls/ntdll/signal_x86_64.c @@ -1858,7 +1858,7 @@ __ASM_GLOBAL_FUNC( set_full_cpu_context, * * Set the new CPU context. Used by NtSetContextThread. */ -void set_cpu_context( const CONTEXT *context ) +static void set_cpu_context( const CONTEXT *context ) { DWORD flags = context->ContextFlags & ~CONTEXT_AMD64; if (flags & CONTEXT_FULL) @@ -2063,6 +2063,21 @@ NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) } +/*********************************************************************** + * NtSetContextThread (NTDLL.@) + * ZwSetContextThread (NTDLL.@) + */ +NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) +{ + NTSTATUS ret; + BOOL self; + + ret = set_thread_context( handle, context, &self ); + if (self && ret == STATUS_SUCCESS) set_cpu_context( context ); + return ret; +} + + extern void raise_func_trampoline( EXCEPTION_RECORD *rec, CONTEXT *context, raise_func func ); __ASM_GLOBAL_FUNC( raise_func_trampoline, __ASM_CFI(".cfi_signal_frame\n\t") @@ -3929,7 +3944,7 @@ __ASM_GLOBAL_FUNC( RtlRaiseException, "movq %rcx,0x80(%rdx)\n\t" /* context->Rcx */ "call " __ASM_NAME("__regs_RtlRaiseException") "\n\t" "leaq 0x20(%rsp),%rdi\n\t" /* context pointer */ - "call " __ASM_NAME("set_cpu_context") /* does not return */ ); + "call " __ASM_NAME("set_full_cpu_context") /* does not return */ ); /************************************************************************* diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 4e1a060..1caa1a3 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -771,7 +771,7 @@ NTSTATUS WINAPI NtQueueApcThread( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1 /*********************************************************************** * set_thread_context */ -static NTSTATUS set_thread_context( HANDLE handle, const CONTEXT *context, BOOL *self ) +NTSTATUS set_thread_context( HANDLE handle, const CONTEXT *context, BOOL *self ) { NTSTATUS ret; DWORD dummy, i; @@ -817,42 +817,6 @@ static NTSTATUS set_thread_context( HANDLE handle, const CONTEXT *context, BOOL } -/*********************************************************************** - * NtSetContextThread (NTDLL.@) - * ZwSetContextThread (NTDLL.@) - */ -NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) -{ - NTSTATUS ret; - BOOL self; - -#ifdef __i386__ - /* on i386 debug registers always require a server call */ - self = (handle == GetCurrentThread()); - if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386))) - { - self = (ntdll_get_thread_data()->dr0 == context->Dr0 && - ntdll_get_thread_data()->dr1 == context->Dr1 && - ntdll_get_thread_data()->dr2 == context->Dr2 && - ntdll_get_thread_data()->dr3 == context->Dr3 && - ntdll_get_thread_data()->dr6 == context->Dr6 && - ntdll_get_thread_data()->dr7 == context->Dr7); - } -#else - self = FALSE; -#endif - - if (!self) - { - ret = set_thread_context( handle, context, &self ); - if (ret) return ret; - } - - if (self) set_cpu_context( context ); - return STATUS_SUCCESS; -} - - /* convert CPU-specific flags to generic server flags */ static inline unsigned int get_server_context_flags( DWORD flags ) {
1
0
0
0
Alexandre Julliard : ntdll: Add helper functions for getting and setting thread context through the server.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: 1e48417567ce976b805b38dd8d1eff6a02e773e9 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1e48417567ce976b805b38dd8…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jul 18 11:07:48 2017 +0200 ntdll: Add helper functions for getting and setting thread context through the server. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/thread.c | 180 +++++++++++++++++++++++++++++----------------------- 1 file changed, 101 insertions(+), 79 deletions(-) diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 830dd3a..4e1a060 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -769,13 +769,61 @@ NTSTATUS WINAPI NtQueueApcThread( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1 /*********************************************************************** + * set_thread_context + */ +static NTSTATUS set_thread_context( HANDLE handle, const CONTEXT *context, BOOL *self ) +{ + NTSTATUS ret; + DWORD dummy, i; + context_t server_context; + + context_to_server( &server_context, context ); + + SERVER_START_REQ( set_thread_context ) + { + req->handle = wine_server_obj_handle( handle ); + req->suspend = 1; + wine_server_add_data( req, &server_context, sizeof(server_context) ); + ret = wine_server_call( req ); + *self = reply->self; + } + SERVER_END_REQ; + + if (ret == STATUS_PENDING) + { + for (i = 0; i < 100; i++) + { + SERVER_START_REQ( set_thread_context ) + { + req->handle = wine_server_obj_handle( handle ); + req->suspend = 0; + wine_server_add_data( req, &server_context, sizeof(server_context) ); + ret = wine_server_call( req ); + } + SERVER_END_REQ; + if (ret == STATUS_PENDING) + { + LARGE_INTEGER timeout; + timeout.QuadPart = -10000; + NtDelayExecution( FALSE, &timeout ); + } + else break; + } + NtResumeThread( handle, &dummy ); + if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED; + } + + return ret; +} + + +/*********************************************************************** * NtSetContextThread (NTDLL.@) * ZwSetContextThread (NTDLL.@) */ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) { NTSTATUS ret; - DWORD dummy, i; BOOL self; #ifdef __i386__ @@ -796,44 +844,7 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) if (!self) { - context_t server_context; - - context_to_server( &server_context, context ); - - SERVER_START_REQ( set_thread_context ) - { - req->handle = wine_server_obj_handle( handle ); - req->suspend = 1; - wine_server_add_data( req, &server_context, sizeof(server_context) ); - ret = wine_server_call( req ); - self = reply->self; - } - SERVER_END_REQ; - - if (ret == STATUS_PENDING) - { - for (i = 0; i < 100; i++) - { - SERVER_START_REQ( set_thread_context ) - { - req->handle = wine_server_obj_handle( handle ); - req->suspend = 0; - wine_server_add_data( req, &server_context, sizeof(server_context) ); - ret = wine_server_call( req ); - } - SERVER_END_REQ; - if (ret == STATUS_PENDING) - { - LARGE_INTEGER timeout; - timeout.QuadPart = -10000; - NtDelayExecution( FALSE, &timeout ); - } - else break; - } - NtResumeThread( handle, &dummy ); - if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED; - } - + ret = set_thread_context( handle, context, &self ); if (ret) return ret; } @@ -866,13 +877,62 @@ static inline unsigned int get_server_context_flags( DWORD flags ) } /*********************************************************************** + * get_thread_context + */ +static NTSTATUS get_thread_context( HANDLE handle, CONTEXT *context, BOOL *self ) +{ + NTSTATUS ret; + DWORD dummy, i; + unsigned int server_flags = get_server_context_flags( context->ContextFlags ); + context_t server_context; + + SERVER_START_REQ( get_thread_context ) + { + req->handle = wine_server_obj_handle( handle ); + req->flags = server_flags; + req->suspend = 1; + wine_server_set_reply( req, &server_context, sizeof(server_context) ); + ret = wine_server_call( req ); + *self = reply->self; + } + SERVER_END_REQ; + + if (ret == STATUS_PENDING) + { + for (i = 0; i < 100; i++) + { + SERVER_START_REQ( get_thread_context ) + { + req->handle = wine_server_obj_handle( handle ); + req->flags = server_flags; + req->suspend = 0; + wine_server_set_reply( req, &server_context, sizeof(server_context) ); + ret = wine_server_call( req ); + } + SERVER_END_REQ; + if (ret == STATUS_PENDING) + { + LARGE_INTEGER timeout; + timeout.QuadPart = -10000; + NtDelayExecution( FALSE, &timeout ); + } + else break; + } + NtResumeThread( handle, &dummy ); + if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED; + } + if (!ret) ret = context_from_server( context, &server_context ); + return ret; +} + + +/*********************************************************************** * NtGetContextThread (NTDLL.@) * ZwGetContextThread (NTDLL.@) */ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) { NTSTATUS ret; - DWORD dummy, i; DWORD needed_flags = context->ContextFlags; BOOL self = (handle == GetCurrentThread()); @@ -885,45 +945,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) if (!self) { - unsigned int server_flags = get_server_context_flags( context->ContextFlags ); - context_t server_context; - - SERVER_START_REQ( get_thread_context ) - { - req->handle = wine_server_obj_handle( handle ); - req->flags = server_flags; - req->suspend = 1; - wine_server_set_reply( req, &server_context, sizeof(server_context) ); - ret = wine_server_call( req ); - self = reply->self; - } - SERVER_END_REQ; - - if (ret == STATUS_PENDING) - { - for (i = 0; i < 100; i++) - { - SERVER_START_REQ( get_thread_context ) - { - req->handle = wine_server_obj_handle( handle ); - req->flags = server_flags; - req->suspend = 0; - wine_server_set_reply( req, &server_context, sizeof(server_context) ); - ret = wine_server_call( req ); - } - SERVER_END_REQ; - if (ret == STATUS_PENDING) - { - LARGE_INTEGER timeout; - timeout.QuadPart = -10000; - NtDelayExecution( FALSE, &timeout ); - } - else break; - } - NtResumeThread( handle, &dummy ); - if (ret == STATUS_PENDING) ret = STATUS_ACCESS_DENIED; - } - if (!ret) ret = context_from_server( context, &server_context ); + ret = get_thread_context( handle, context, &self ); if (ret) return ret; needed_flags &= ~context->ContextFlags; }
1
0
0
0
Alexandre Julliard : ntdll: Remove unnecessary helper to set debug registers.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: da6ca91e28045719505e4cf091520f8f074746da URL:
http://source.winehq.org/git/wine.git/?a=commit;h=da6ca91e28045719505e4cf09…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jul 18 10:36:52 2017 +0200 ntdll: Remove unnecessary helper to set debug registers. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_i386.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 59dca6c..d9a0dec 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1266,35 +1266,6 @@ void set_cpu_context( const CONTEXT *context ) /*********************************************************************** - * set_debug_registers - */ -static void set_debug_registers( const CONTEXT *context ) -{ - DWORD flags = context->ContextFlags & ~CONTEXT_i386; - context_t server_context; - - if (!(flags & CONTEXT_DEBUG_REGISTERS)) return; - if (ntdll_get_thread_data()->dr0 == context->Dr0 && - ntdll_get_thread_data()->dr1 == context->Dr1 && - ntdll_get_thread_data()->dr2 == context->Dr2 && - ntdll_get_thread_data()->dr3 == context->Dr3 && - ntdll_get_thread_data()->dr6 == context->Dr6 && - ntdll_get_thread_data()->dr7 == context->Dr7) return; - - context_to_server( &server_context, context ); - - SERVER_START_REQ( set_thread_context ) - { - req->handle = wine_server_obj_handle( GetCurrentThread() ); - req->suspend = 0; - wine_server_add_data( req, &server_context, sizeof(server_context) ); - wine_server_call( req ); - } - SERVER_END_REQ; -} - - -/*********************************************************************** * copy_context * * Copy a register context according to the flags. @@ -2647,11 +2618,7 @@ DEFINE_REGS_ENTRYPOINT( RtlUnwind, 4 ) NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) { NTSTATUS status = raise_exception( rec, context, first_chance ); - if (status == STATUS_SUCCESS) - { - set_debug_registers( context ); - set_cpu_context( context ); - } + if (status == STATUS_SUCCESS) NtSetContextThread( GetCurrentThread(), context ); return status; }
1
0
0
0
Jacek Caban : winhttp/tests: Added persistent connection tests.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: fa2cc9868b7db7a4cbf7d01a48500cb3f31e109a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fa2cc9868b7db7a4cbf7d01a4…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Jul 18 00:25:27 2017 +0200 winhttp/tests: Added persistent connection tests. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winhttp/tests/notification.c | 429 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 429 insertions(+) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=fa2cc9868b7db7a4cbf7d…
1
0
0
0
Jacek Caban : winhttp: Periodically free outdated connections.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: 2a99f0e3b3a8e353c2d9de6893b230f2ce985e71 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2a99f0e3b3a8e353c2d9de689…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Jul 18 00:25:20 2017 +0200 winhttp: Periodically free outdated connections. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winhttp/main.c | 8 ++--- dlls/winhttp/request.c | 67 ++++++++++++++++++++++++++++++++++++++++++ dlls/winhttp/winhttp_private.h | 3 ++ 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/dlls/winhttp/main.c b/dlls/winhttp/main.c index cd2d114..a63f28c 100644 --- a/dlls/winhttp/main.c +++ b/dlls/winhttp/main.c @@ -30,7 +30,7 @@ #include "wine/debug.h" #include "winhttp_private.h" -static HINSTANCE instance; +HINSTANCE winhttp_instance; WINE_DEFAULT_DEBUG_CHANNEL(winhttp); @@ -42,7 +42,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) switch(fdwReason) { case DLL_PROCESS_ATTACH: - instance = hInstDLL; + winhttp_instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); break; case DLL_PROCESS_DETACH: @@ -169,7 +169,7 @@ HRESULT WINAPI DllCanUnloadNow(void) */ HRESULT WINAPI DllRegisterServer(void) { - return __wine_register_resources( instance ); + return __wine_register_resources( winhttp_instance ); } /*********************************************************************** @@ -177,5 +177,5 @@ HRESULT WINAPI DllRegisterServer(void) */ HRESULT WINAPI DllUnregisterServer(void) { - return __wine_unregister_resources( instance ); + return __wine_unregister_resources( winhttp_instance ); } diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index a9f44eaf..47cc906 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -43,6 +43,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(winhttp); +#define DEFAULT_KEEP_ALIVE_TIMEOUT 30000 + static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0}; static const WCHAR attr_accept_charset[] = {'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0}; static const WCHAR attr_accept_encoding[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0}; @@ -1016,12 +1018,77 @@ void release_host( host_t *host ) heap_free( host ); } +static BOOL connection_collector_running; + +static DWORD WINAPI connection_collector(void *arg) +{ + unsigned int remaining_connections; + netconn_t *netconn, *next_netconn; + host_t *host, *next_host; + ULONGLONG now; + + do + { + /* FIXME: Use more sophisticated method */ + Sleep(5000); + remaining_connections = 0; + now = GetTickCount64(); + + EnterCriticalSection(&connection_pool_cs); + + LIST_FOR_EACH_ENTRY_SAFE(host, next_host, &connection_pool, host_t, entry) + { + LIST_FOR_EACH_ENTRY_SAFE(netconn, next_netconn, &host->connections, netconn_t, entry) + { + if (netconn->keep_until < now) + { + TRACE("freeing %p\n", netconn); + list_remove(&netconn->entry); + netconn_close(netconn); + } + else + { + remaining_connections++; + } + } + } + + if (!remaining_connections) connection_collector_running = FALSE; + + LeaveCriticalSection(&connection_pool_cs); + } while(remaining_connections); + + FreeLibraryAndExitThread( winhttp_instance, 0 ); +} + static void cache_connection( netconn_t *netconn ) { TRACE( "caching connection %p\n", netconn ); EnterCriticalSection( &connection_pool_cs ); + + netconn->keep_until = GetTickCount64() + DEFAULT_KEEP_ALIVE_TIMEOUT; list_add_head( &netconn->host->connections, &netconn->entry ); + + if (!connection_collector_running) + { + HMODULE module; + HANDLE thread; + + GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR*)winhttp_instance, &module ); + + thread = CreateThread(NULL, 0, connection_collector, NULL, 0, NULL); + if (thread) + { + CloseHandle( thread ); + connection_collector_running = TRUE; + } + else + { + FreeLibrary( winhttp_instance ); + } + } + LeaveCriticalSection( &connection_pool_cs ); } diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 6d27f22..dd8c4ef 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -143,6 +143,7 @@ typedef struct struct sockaddr_storage sockaddr; BOOL secure; /* SSL active on connection? */ host_t *host; + ULONGLONG keep_until; CtxtHandle ssl_ctx; SecPkgContext_StreamSizes ssl_sizes; char *ssl_buf; @@ -392,4 +393,6 @@ static inline char *strdupWA_sized( const WCHAR *src, DWORD size ) return dst; } +extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN; + #endif /* _WINE_WINHTTP_PRIVATE_H_ */
1
0
0
0
Jacek Caban : winhttp: Cache and reuse persistent HTTP connections.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: 5226865c5324f366ad6974ddb8291adc20759019 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5226865c5324f366ad6974ddb…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Jul 18 00:25:15 2017 +0200 winhttp: Cache and reuse persistent HTTP connections. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winhttp/net.c | 30 ++++++++++ dlls/winhttp/request.c | 113 ++++++++++++++++++++++++++++---------- dlls/winhttp/tests/notification.c | 2 - dlls/winhttp/winhttp_private.h | 3 + 4 files changed, 116 insertions(+), 32 deletions(-) diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index c57d3af..8c60329 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -772,6 +772,36 @@ DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value ) return ERROR_SUCCESS; } +BOOL netconn_is_alive( netconn_t *netconn ) +{ +#ifdef MSG_DONTWAIT + ssize_t len; + BYTE b; + + len = recv( netconn->socket, &b, 1, MSG_PEEK | MSG_DONTWAIT ); + return len == 1 || (len == -1 && errno == EWOULDBLOCK); +#elif defined(__MINGW32__) || defined(_MSC_VER) + ULONG mode; + int len; + char b; + + mode = 1; + if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) + return FALSE; + + len = recv(netconn->socket, &b, 1, MSG_PEEK); + + mode = 0; + if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) + return FALSE; + + return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK); +#else + FIXME("not supported on this platform\n"); + return TRUE; +#endif +} + static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_storage *sa ) { char *hostname; diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 97e4ce0..a9f44eaf 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1011,15 +1011,25 @@ void release_host( host_t *host ) LeaveCriticalSection( &connection_pool_cs ); if (ref) return; + assert( list_empty( &host->connections ) ); heap_free( host->hostname ); heap_free( host ); } +static void cache_connection( netconn_t *netconn ) +{ + TRACE( "caching connection %p\n", netconn ); + + EnterCriticalSection( &connection_pool_cs ); + list_add_head( &netconn->host->connections, &netconn->entry ); + LeaveCriticalSection( &connection_pool_cs ); +} + static BOOL open_connection( request_t *request ) { BOOL is_secure = request->hdr.flags & WINHTTP_FLAG_SECURE; host_t *host = NULL, *iter; - netconn_t *netconn; + netconn_t *netconn = NULL; connect_t *connect; WCHAR *addressW = NULL; INTERNET_PORT port; @@ -1048,6 +1058,7 @@ static BOOL open_connection( request_t *request ) host->ref = 1; host->secure = is_secure; host->port = port; + list_init( &host->connections ); if ((host->hostname = strdupW( connect->servername ))) { list_add_head( &connection_pool, &host->entry ); @@ -1063,6 +1074,29 @@ static BOOL open_connection( request_t *request ) if (!host) return FALSE; + for (;;) + { + EnterCriticalSection( &connection_pool_cs ); + if (!list_empty( &host->connections )) + { + netconn = LIST_ENTRY( list_head( &host->connections ), netconn_t, entry ); + list_remove( &netconn->entry ); + } + LeaveCriticalSection( &connection_pool_cs ); + if (!netconn) break; + + if (netconn_is_alive( netconn )) break; + TRACE("connection %p no longer alive, closing\n", netconn); + netconn_close( netconn ); + netconn = NULL; + } + + if (!connect->resolved && netconn) + { + connect->sockaddr = netconn->sockaddr; + connect->resolved = TRUE; + } + if (!connect->resolved) { len = strlenW( host->hostname ) + 1; @@ -1084,47 +1118,57 @@ static BOOL open_connection( request_t *request ) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, len ); } - if (!addressW && !(addressW = addr_to_str( &connect->sockaddr ))) + if (!netconn) { - release_host( host ); - return FALSE; - } + if (!addressW && !(addressW = addr_to_str( &connect->sockaddr ))) + { + release_host( host ); + return FALSE; + } - TRACE("connecting to %s:%u\n", debugstr_w(addressW), port); + TRACE("connecting to %s:%u\n", debugstr_w(addressW), port); - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); - netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout ); - if (!netconn) - { - release_host( host ); - heap_free( addressW ); - return FALSE; - } - netconn_set_timeout( netconn, TRUE, request->send_timeout ); - netconn_set_timeout( netconn, FALSE, request->recv_timeout ); - if (request->hdr.flags & WINHTTP_FLAG_SECURE) - { - if (connect->session->proxy_server && - strcmpiW( connect->hostname, connect->servername )) + if (!(netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout ))) { - if (!secure_proxy_connect( request )) + heap_free( addressW ); + release_host( host ); + return FALSE; + } + netconn_set_timeout( netconn, TRUE, request->send_timeout ); + netconn_set_timeout( netconn, FALSE, request->recv_timeout ); + if (is_secure) + { + if (connect->session->proxy_server && + strcmpiW( connect->hostname, connect->servername )) + { + if (!secure_proxy_connect( request )) + { + heap_free( addressW ); + netconn_close( netconn ); + return FALSE; + } + } + if (!netconn_secure_connect( netconn, connect->hostname, request->security_flags )) { heap_free( addressW ); netconn_close( netconn ); return FALSE; } } - if (!netconn_secure_connect( netconn, connect->hostname, request->security_flags )) - { - netconn_close( netconn ); - heap_free( addressW ); - return FALSE; - } + + request->netconn = netconn; + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 ); } - request->netconn = netconn; + else + { + TRACE("using connection %p\n", netconn); - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 ); + netconn_set_timeout( netconn, TRUE, request->send_timeout ); + netconn_set_timeout( netconn, FALSE, request->recv_timeout ); + request->netconn = netconn; + } done: request->read_pos = request->read_size = 0; @@ -1309,6 +1353,8 @@ static void finished_reading( request_t *request ) WCHAR connection[20]; DWORD size = sizeof(connection); + if (!request->netconn) return; + if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE; else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) || query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL )) @@ -1316,7 +1362,14 @@ static void finished_reading( request_t *request ) if (!strcmpiW( connection, closeW )) close = TRUE; } else if (!strcmpW( request->version, http1_0 )) close = TRUE; - if (close) close_connection( request ); + if (close) + { + close_connection( request ); + return; + } + + cache_connection( request->netconn ); + request->netconn = NULL; } /* return the size of data available to be read immediately */ diff --git a/dlls/winhttp/tests/notification.c b/dlls/winhttp/tests/notification.c index e9de152..15fabcd8 100644 --- a/dlls/winhttp/tests/notification.c +++ b/dlls/winhttp/tests/notification.c @@ -484,8 +484,6 @@ static const struct notification async_test[] = { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 2b171bf..6d27f22 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -102,6 +102,7 @@ typedef struct { WCHAR *hostname; INTERNET_PORT port; BOOL secure; + struct list connections; } host_t; typedef struct @@ -137,6 +138,7 @@ typedef struct typedef struct { + struct list entry; int socket; struct sockaddr_storage sockaddr; BOOL secure; /* SSL active on connection? */ @@ -300,6 +302,7 @@ BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) D BOOL netconn_secure_connect( netconn_t *, WCHAR *, DWORD ) DECLSPEC_HIDDEN; BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN; DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN; +BOOL netconn_is_alive( netconn_t * ) DECLSPEC_HIDDEN; const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN; int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
1
0
0
0
Jacek Caban : winhttp: Introduce global connected hosts store and keep reference to host in netconn_t.
by Alexandre Julliard
18 Jul '17
18 Jul '17
Module: wine Branch: master Commit: e0e8a3ff77466b66880df30cbf0fe3619a9ba880 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=e0e8a3ff77466b66880df30cb…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Tue Jul 18 00:25:10 2017 +0200 winhttp: Introduce global connected hosts store and keep reference to host in netconn_t. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winhttp/net.c | 4 +- dlls/winhttp/request.c | 88 +++++++++++++++++++++++++++++++++++++++--- dlls/winhttp/winhttp_private.h | 13 ++++++- 3 files changed, 97 insertions(+), 8 deletions(-) diff --git a/dlls/winhttp/net.c b/dlls/winhttp/net.c index 32d3624..c57d3af 100644 --- a/dlls/winhttp/net.c +++ b/dlls/winhttp/net.c @@ -299,7 +299,7 @@ void netconn_unload( void ) #endif } -netconn_t *netconn_create( const struct sockaddr_storage *sockaddr, int timeout ) +netconn_t *netconn_create( host_t *host, const struct sockaddr_storage *sockaddr, int timeout ) { netconn_t *conn; unsigned int addr_len; @@ -309,6 +309,7 @@ netconn_t *netconn_create( const struct sockaddr_storage *sockaddr, int timeout conn = heap_alloc_zero(sizeof(*conn)); if (!conn) return NULL; + conn->host = host; conn->sockaddr = *sockaddr; if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1) { @@ -398,6 +399,7 @@ BOOL netconn_close( netconn_t *conn ) DeleteSecurityContext(&conn->ssl_ctx); } res = closesocket( conn->socket ); + release_host( conn->host ); heap_free(conn); if (res == -1) { diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 5afc768..97e4ce0 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -991,8 +991,34 @@ static WCHAR *addr_to_str( struct sockaddr_storage *addr ) return strdupAW( buf ); } +static CRITICAL_SECTION connection_pool_cs; +static CRITICAL_SECTION_DEBUG connection_pool_debug = +{ + 0, 0, &connection_pool_cs, + { &connection_pool_debug.ProcessLocksList, &connection_pool_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": connection_pool_cs") } +}; +static CRITICAL_SECTION connection_pool_cs = { &connection_pool_debug, -1, 0, 0, 0, 0 }; + +static struct list connection_pool = LIST_INIT( connection_pool ); + +void release_host( host_t *host ) +{ + LONG ref; + + EnterCriticalSection( &connection_pool_cs ); + if (!(ref = --host->ref)) list_remove( &host->entry ); + LeaveCriticalSection( &connection_pool_cs ); + if (ref) return; + + heap_free( host->hostname ); + heap_free( host ); +} + static BOOL open_connection( request_t *request ) { + BOOL is_secure = request->hdr.flags & WINHTTP_FLAG_SECURE; + host_t *host = NULL, *iter; netconn_t *netconn; connect_t *connect; WCHAR *addressW = NULL; @@ -1004,25 +1030,74 @@ static BOOL open_connection( request_t *request ) connect = request->connect; port = connect->serverport ? connect->serverport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80); + EnterCriticalSection( &connection_pool_cs ); + + LIST_FOR_EACH_ENTRY( iter, &connection_pool, host_t, entry ) + { + if (iter->port == port && !strcmpW( connect->servername, iter->hostname ) && !is_secure == !iter->secure) + { + host = iter; + host->ref++; + break; + } + } + + if (!host) + { + if (!(host = heap_alloc( sizeof(*host) ))) return FALSE; + host->ref = 1; + host->secure = is_secure; + host->port = port; + if ((host->hostname = strdupW( connect->servername ))) + { + list_add_head( &connection_pool, &host->entry ); + } + else + { + heap_free( host ); + host = NULL; + } + } + + LeaveCriticalSection( &connection_pool_cs ); + + if (!host) return FALSE; + if (!connect->resolved) { - len = strlenW( connect->servername ) + 1; - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, connect->servername, len ); + len = strlenW( host->hostname ) + 1; + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, host->hostname, len ); - if (!netconn_resolve( connect->servername, port, &connect->sockaddr, request->resolve_timeout )) return FALSE; + if (!netconn_resolve( host->hostname, port, &connect->sockaddr, request->resolve_timeout )) + { + release_host( host ); + return FALSE; + } connect->resolved = TRUE; - if (!(addressW = addr_to_str( &connect->sockaddr ))) return FALSE; + if (!(addressW = addr_to_str( &connect->sockaddr ))) + { + release_host( host ); + return FALSE; + } len = strlenW( addressW ) + 1; send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, len ); } - if (!addressW && !(addressW = addr_to_str( &connect->sockaddr ))) return FALSE; + + if (!addressW && !(addressW = addr_to_str( &connect->sockaddr ))) + { + release_host( host ); + return FALSE; + } + TRACE("connecting to %s:%u\n", debugstr_w(addressW), port); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); - if (!(netconn = netconn_create( &connect->sockaddr, request->connect_timeout ))) + netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout ); + if (!netconn) { + release_host( host ); heap_free( addressW ); return FALSE; } @@ -1036,6 +1111,7 @@ static BOOL open_connection( request_t *request ) if (!secure_proxy_connect( request )) { heap_free( addressW ); + netconn_close( netconn ); return FALSE; } } diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h index 611dc43..2b171bf 100644 --- a/dlls/winhttp/winhttp_private.h +++ b/dlls/winhttp/winhttp_private.h @@ -96,6 +96,14 @@ typedef struct WCHAR *path; } cookie_t; +typedef struct { + struct list entry; + LONG ref; + WCHAR *hostname; + INTERNET_PORT port; + BOOL secure; +} host_t; + typedef struct { object_header_t hdr; @@ -132,6 +140,7 @@ typedef struct int socket; struct sockaddr_storage sockaddr; BOOL secure; /* SSL active on connection? */ + host_t *host; CtxtHandle ssl_ctx; SecPkgContext_StreamSizes ssl_sizes; char *ssl_buf; @@ -283,7 +292,7 @@ void send_callback( object_header_t *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN; void close_connection( request_t * ) DECLSPEC_HIDDEN; BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN; -netconn_t *netconn_create( const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; +netconn_t *netconn_create( host_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; void netconn_unload( void ) DECLSPEC_HIDDEN; ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN; BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN; @@ -301,6 +310,8 @@ void delete_domain( domain_t * ) DECLSPEC_HIDDEN; BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN; void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN; +void release_host( host_t *host ) DECLSPEC_HIDDEN; + extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN; void release_typelib( void ) DECLSPEC_HIDDEN;
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
...
64
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Results per page:
10
25
50
100
200