Commit 50bea867 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

winhttp: Move read buffer to websocket.

parent e50df0fa
...@@ -3192,6 +3192,7 @@ static void socket_destroy( struct object_header *hdr ) ...@@ -3192,6 +3192,7 @@ static void socket_destroy( struct object_header *hdr )
netconn_release( socket->netconn ); netconn_release( socket->netconn );
release_object( &socket->request->hdr ); release_object( &socket->request->hdr );
free( socket->read_buffer );
free( socket->send_frame_buffer ); free( socket->send_frame_buffer );
free( socket ); free( socket );
} }
...@@ -3266,6 +3267,19 @@ HINTERNET WINAPI WinHttpWebSocketCompleteUpgrade( HINTERNET hrequest, DWORD_PTR ...@@ -3266,6 +3267,19 @@ HINTERNET WINAPI WinHttpWebSocketCompleteUpgrade( HINTERNET hrequest, DWORD_PTR
socket->hdr.flags = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC; socket->hdr.flags = request->connect->hdr.flags & WINHTTP_FLAG_ASYNC;
socket->keepalive_interval = 30000; socket->keepalive_interval = 30000;
socket->send_buffer_size = request->websocket_send_buffer_size; socket->send_buffer_size = request->websocket_send_buffer_size;
if (request->read_size)
{
if (!(socket->read_buffer = malloc( request->read_size )))
{
ERR( "No memory.\n" );
free( socket );
release_object( &request->hdr );
return NULL;
}
socket->bytes_in_read_buffer = request->read_size;
memcpy( socket->read_buffer, request->read_buf + request->read_pos, request->read_size );
request->read_pos = request->read_size = 0;
}
InitializeSRWLock( &socket->send_lock ); InitializeSRWLock( &socket->send_lock );
init_queue( &socket->send_q ); init_queue( &socket->send_q );
init_queue( &socket->recv_q ); init_queue( &socket->recv_q );
...@@ -3674,11 +3688,12 @@ static DWORD receive_bytes( struct socket *socket, char *buf, DWORD len, DWORD * ...@@ -3674,11 +3688,12 @@ static DWORD receive_bytes( struct socket *socket, char *buf, DWORD len, DWORD *
char *ptr = buf; char *ptr = buf;
int received; int received;
if (socket->request->read_size) if (socket->bytes_in_read_buffer)
{ {
size = min( needed, socket->request->read_size ); size = min( needed, socket->bytes_in_read_buffer );
memcpy( ptr, socket->request->read_buf + socket->request->read_pos, size ); memcpy( ptr, socket->read_buffer, size );
remove_data( socket->request, size ); memmove( socket->read_buffer, socket->read_buffer + size, socket->bytes_in_read_buffer - size );
socket->bytes_in_read_buffer -= size;
needed -= size; needed -= size;
ptr += size; ptr += size;
} }
......
...@@ -277,6 +277,8 @@ struct socket ...@@ -277,6 +277,8 @@ struct socket
unsigned int send_remaining_size; unsigned int send_remaining_size;
unsigned int bytes_in_send_frame_buffer; unsigned int bytes_in_send_frame_buffer;
unsigned int client_buffer_offset; unsigned int client_buffer_offset;
char *read_buffer;
unsigned int bytes_in_read_buffer;
SRWLOCK send_lock; SRWLOCK send_lock;
volatile LONG pending_noncontrol_send; volatile LONG pending_noncontrol_send;
enum fragment_type sending_fragment_type; enum fragment_type sending_fragment_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment