Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Open
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
12 changes: 7 additions & 5 deletions GCDWebServer/Core/GCDWebServerConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ - (void)writeBodyWithCompletionBlock:(WriteBodyCompletionBlock)block;
@implementation GCDWebServerConnection {
CFSocketNativeHandle _socket;
BOOL _virtualHEAD;


dispatch_queue_t _dataQueue ;
CFHTTPMessageRef _requestMessage;
GCDWebServerRequest* _request;
GCDWebServerHandler* _handler;
Expand Down Expand Up @@ -363,7 +364,8 @@ - (instancetype)initWithServer:(GCDWebServer*)server localAddress:(NSData*)local
_remoteAddressData = remoteAddress;
_socket = socket;
GWS_LOG_DEBUG(@"Did open connection on socket %i", _socket);


_dataQueue = dispatch_queue_create("gcdwebserver.connection.data", DISPATCH_QUEUE_SERIAL) ;
[_server willStartConnection:self];

if (![self open]) {
Expand Down Expand Up @@ -413,7 +415,7 @@ - (void)dealloc {
@implementation GCDWebServerConnection (Read)

- (void)readData:(NSMutableData*)data withLength:(NSUInteger)length completionBlock:(ReadDataCompletionBlock)block {
dispatch_read(_socket, length, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^(dispatch_data_t buffer, int error) {
dispatch_read(_socket, length, _dataQueue, ^(dispatch_data_t buffer, int error) {
@autoreleasepool {
if (error == 0) {
size_t size = dispatch_data_get_size(buffer);
Expand Down Expand Up @@ -570,10 +572,10 @@ - (void)readNextBodyChunk:(NSMutableData*)chunkData completionBlock:(ReadBodyCom
@implementation GCDWebServerConnection (Write)

- (void)writeData:(NSData*)data withCompletionBlock:(WriteDataCompletionBlock)block {
dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^{
dispatch_data_t buffer = dispatch_data_create(data.bytes, data.length, _dataQueue, ^{
[data self]; // Keeps ARC from releasing data too early
});
dispatch_write(_socket, buffer, dispatch_get_global_queue(_server.dispatchQueuePriority, 0), ^(dispatch_data_t remainingData, int error) {
dispatch_write(_socket, buffer, _dataQueue, ^(dispatch_data_t remainingData, int error) {
@autoreleasepool {
if (error == 0) {
GWS_DCHECK(remainingData == NULL);
Expand Down