Skip to content

Commit

Permalink
Fix HTTP transfer-encoding:chunk. Fixed some missing connect_issued f…
Browse files Browse the repository at this point in the history
…lag updates. Fixed a missing close-socket path in HTTPS flow.
  • Loading branch information
serverdev committed Oct 6, 2024
1 parent 696dddc commit b3cec8d
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 141 deletions.
1 change: 1 addition & 0 deletions include/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct HTTPRequestOptions {
uintptr_t userData;
LOGICAL connected; // did get a connect state, so connectError is not checked... (timeout before connect complete?)
int connectError; // feedback to application if there was an error connecting.
const char *hostname;
};

typedef struct HttpState *HTTPState;
Expand Down
4 changes: 4 additions & 0 deletions src/netlib/network_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ int CPROC ProcessNetworkMessages( struct peer_thread_info *thread, uintptr_t non
getsockopt( event_data->pc->Socket, SOL_SOCKET
, SO_ERROR
, &error, &errlen );
// errors like EHOSTUNREACH/ENETUNREACH happen in connect()
// and result immediately so they do not get delayed until here.
//lprintf( "Error checking for connect is: %s on %p", strerror( error ), event_data->pc );
if( event_data->pc->pWaiting ) {
#ifdef LOG_NOTICES
Expand All @@ -606,6 +608,8 @@ int CPROC ProcessNetworkMessages( struct peer_thread_info *thread, uintptr_t non
if( error ) {
event_data->pc->dwFlags |= CF_CONNECTERROR;
}
// have to allow SSL to clear this... so set it before calling the connect callback.
event_data->pc->dwFlags |= CF_CONNECT_ISSUED;
if( event_data->pc->dwFlags & CF_CPPCONNECT ) {
if( event_data->pc->connect.CPPThisConnected )
event_data->pc->connect.CPPThisConnected( event_data->pc->psvConnect, error );
Expand Down
2 changes: 2 additions & 0 deletions src/netlib/network_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ static void HandleEvent( PCLIENT pClient )
if( globalNetworkData.flags.bLogNotices )
lprintf( "Post connect to application %p error:%d", pClient, wError );
#endif
// have to allow SSL to clear this... so set it before calling the connect callback.
pClient->dwFlags |= CF_CONNECT_ISSUED;
if( pClient->dwFlags & CF_CPPCONNECT )
pClient->connect.CPPThisConnected( pClient->psvConnect, wError );
else
Expand Down
13 changes: 8 additions & 5 deletions src/netlib/ssl_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ static void ssl_ReadComplete_( PCLIENT pc, struct ssl_session** ses, POINTER buf
if( !( hs_rc = handshake( ses ) ) ) {
// zero result is 'needs more data read'
if( !ses[0] ) {
ses[0]->inUse--;
LeaveCriticalSec( &ses[0]->csReadWrite ); //-V522
lprintf( "IN handshake, the session disappeared?");
return;
}
#ifdef DEBUG_SSL_IO_VERBOSE
Expand Down Expand Up @@ -654,17 +653,21 @@ static void ssl_ReadComplete_( PCLIENT pc, struct ssl_session** ses, POINTER buf
if( ses[0] ) { // might have closed during read.
if( ses[0] && ses[0]->deleteInUse ){
//lprintf( "Pending close(3)... was in-use when closed.");
ses[0]->inUse--;
RemoveClient( pc );
}
else {
EnterCriticalSec( &ses[0]->csReadWrite );
goto read_more;
}
EnterCriticalSec( &ses[0]->csReadWrite );
goto read_more;
} else {
//lprintf( "Session closed during read." );
}
}
else if( len == 0 ) {
ses[0]->inUse--;
#ifdef DEBUG_SSL_IO_VERBOSE
lprintf( "incomplete read" );
lprintf( "incomplete read (no more data to read)" );
#endif
}

Expand Down
Loading

0 comments on commit b3cec8d

Please sign in to comment.