Skip to content

Commit

Permalink
Bump uS
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed May 12, 2023
1 parent e215325 commit 9db254a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/AsyncSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct AsyncSocket {
}

/* Cork this socket. Only one socket may ever be corked per-loop at any given time */
void cork() {
void cork(char *sendBuffer = nullptr) {
/* Extra check for invalid corking of others */
if (getLoopData()->corkOffset && getLoopData()->corkedSocket != this) {
std::cerr << "Error: Cork buffer must not be acquired without checking canCork!" << std::endl;
Expand All @@ -139,6 +139,15 @@ struct AsyncSocket {

/* What if another socket is corked? */
getLoopData()->corkedSocket = this;

if (sendBuffer) {
setCorkBuffer(sendBuffer, 0);
}
}

void setCorkBuffer(char *buffer, int offset) {
getLoopData()->corkBuffer = buffer;
getLoopData()->corkOffset = offset;
}

/* Returns the corked socket or nullptr */
Expand Down
2 changes: 1 addition & 1 deletion src/HttpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct HttpContext {
HttpResponseData<SSL> *httpResponseData = (HttpResponseData<SSL> *) us_socket_ext(SSL, s);

/* Cork this socket */
((AsyncSocket<SSL> *) s)->cork();
((AsyncSocket<SSL> *) s)->cork(us_socket_send_buffer(0, s));

/* Mark that we are inside the parser now */
httpContextData->isParsingHttp = true;
Expand Down
2 changes: 1 addition & 1 deletion src/WebSocketContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ struct WebSocketContext {
webSocketData->hasTimedOut = false;

/* We always cork on data */
asyncSocket->cork();
asyncSocket->cork(us_socket_send_buffer(0, s));

/* This parser has virtually no overhead */
WebSocketProtocol<isServer, WebSocketContext<SSL, isServer, USERDATA>>::consume(data, (unsigned int) length, (WebSocketState<isServer> *) webSocketData, s);
Expand Down
2 changes: 1 addition & 1 deletion uSockets

0 comments on commit 9db254a

Please sign in to comment.